feat: packaging, project structure + updated README.md
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -3,3 +3,5 @@ __pycache__
|
|||||||
*.npz
|
*.npz
|
||||||
*.npy
|
*.npy
|
||||||
.venv
|
.venv
|
||||||
|
dist
|
||||||
|
*.egg-info
|
||||||
31
README.md
31
README.md
@@ -2,24 +2,33 @@
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
1. Install requirements :
|
1. To install from source :
|
||||||
```sh
|
```sh
|
||||||
$ pip install -r requirements.txt
|
$ git clone git@github.com:lenoctambule/autoencoder.git
|
||||||
|
$ pip install -e autoencoder/
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Optionally run mnist_test.py.
|
2. Optionally, run mnist_test.py to see it in action on the MNIST dataset.
|
||||||
```sh
|
```sh
|
||||||
|
$ cd examples
|
||||||
$ py mnist_test.py
|
$ py mnist_test.py
|
||||||
```
|
```
|
||||||
|
|
||||||
## Training
|
## Training
|
||||||
|
|
||||||
Instatiate an `Autoencoder` object :
|
Instatiate an `ClassicalAutoencoder` or `VariationalAutoencoder` object :
|
||||||
```py
|
```py
|
||||||
from autoencoder import Autoencoder
|
from easyvae.autoencoder import ClassicalAutoencoder, VariationalAutoencoder
|
||||||
from activations import LeakyReLU
|
from easyvae.activations import LeakyReLU
|
||||||
|
|
||||||
autoencoder = Autoencoder(
|
autoencoder = ClassicalAutoencoder(
|
||||||
|
[768, 64, 16],
|
||||||
|
[16, 64, 768],
|
||||||
|
0.01,
|
||||||
|
LeakyReLU()
|
||||||
|
)
|
||||||
|
# or
|
||||||
|
autoencoder = VariationalAutoencoder(
|
||||||
[768, 64, 16],
|
[768, 64, 16],
|
||||||
[16, 64, 768],
|
[16, 64, 768],
|
||||||
0.01,
|
0.01,
|
||||||
@@ -30,11 +39,17 @@ And then via the `train_dataset` method to train over a dataset :
|
|||||||
```py
|
```py
|
||||||
autoencoder.train_dataset(data)
|
autoencoder.train_dataset(data)
|
||||||
```
|
```
|
||||||
Or via the `train` to input each data points iteratively :
|
Or via the `train` method to input each data points iteratively :
|
||||||
```py
|
```py
|
||||||
autoencoder.train(v)
|
autoencoder.train(v)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
After training, you can save your model via the `save` method and load that model using `load` method :
|
||||||
|
```
|
||||||
|
autoencoder.save("mymodel.npy)
|
||||||
|
autoencoder.load("mymodel.npy")
|
||||||
|
```
|
||||||
|
|
||||||
## Inference
|
## Inference
|
||||||
|
|
||||||
Use your `Autoencoder` object with the `encode`, `decode`, `forward` methods like so :
|
Use your `Autoencoder` object with the `encode`, `decode`, `forward` methods like so :
|
||||||
|
|||||||
@@ -2,10 +2,12 @@ import matplotlib.pyplot as plt
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
import os
|
import os
|
||||||
import signal
|
import signal
|
||||||
from autoencoder import (VariationalAutoencoder, # noqa
|
from easyvae.autoencoder import ( # noqa
|
||||||
ClassicalAutoencoder,
|
VariationalAutoencoder,
|
||||||
AAutoencoder)
|
ClassicalAutoencoder,
|
||||||
from activations import LeakyReLU
|
AAutoencoder
|
||||||
|
)
|
||||||
|
from easyvae.activations import LeakyReLU
|
||||||
|
|
||||||
|
|
||||||
def load_mnist() -> list[np.ndarray]:
|
def load_mnist() -> list[np.ndarray]:
|
||||||
23
pyproject.toml
Normal file
23
pyproject.toml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
[project]
|
||||||
|
name = "easyvae"
|
||||||
|
version = "1.0"
|
||||||
|
authors = [
|
||||||
|
{ name="Ravaka RALAMBOARIVONY", email="ravaka.rlb.pro@gmail.com" },
|
||||||
|
]
|
||||||
|
description = "Python implementation of a Classical and Variational Autoencoders "
|
||||||
|
readme = "README.md"
|
||||||
|
requires-python = ">=3.10"
|
||||||
|
classifiers = [
|
||||||
|
"Programming Language :: Python :: 3",
|
||||||
|
"Operating System :: OS Independent",
|
||||||
|
]
|
||||||
|
license = "MIT"
|
||||||
|
license-files = ["LICEN[CS]E*"]
|
||||||
|
|
||||||
|
[project.urls]
|
||||||
|
Homepage = "https://github.com/lenoctambule/autoencoder"
|
||||||
|
Issues = "https://github.com/lenoctambule/autoencoder/issues"
|
||||||
|
|
||||||
|
[build-system]
|
||||||
|
requires = ["setuptools"]
|
||||||
|
build-backend = "setuptools.build_meta"
|
||||||
0
src/easyvae/__init__.py
Normal file
0
src/easyvae/__init__.py
Normal file
@@ -1,10 +1,12 @@
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
from utils import (dynamic_loss_plot_init,
|
from .utils import (
|
||||||
dynamic_loss_plot_update,
|
dynamic_loss_plot_init,
|
||||||
dynamic_loss_plot_finish)
|
dynamic_loss_plot_update,
|
||||||
|
dynamic_loss_plot_finish
|
||||||
|
)
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
from layers import DeepNNLayer, SampleLayer
|
from .layers import DeepNNLayer, SampleLayer
|
||||||
from activations import ActivationFunc, Identity
|
from .activations import ActivationFunc, Identity
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
|
|
||||||
LOADER = ['⡿', '⣟', '⣯', '⣷', '⣾', '⣽', '⣻', '⢿']
|
LOADER = ['⡿', '⣟', '⣯', '⣷', '⣾', '⣽', '⣻', '⢿']
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
from activations import ActivationFunc, Identity
|
from .activations import ActivationFunc, Identity
|
||||||
|
|
||||||
|
|
||||||
class NNLayer:
|
class NNLayer:
|
||||||
Reference in New Issue
Block a user