b4963513cc83b565ed2e6a9307b12d8d1ec92fa9
Python AutoEncoder from scratch using Numpy
Usage
- To install from source :
$ git clone git@github.com:lenoctambule/autoencoder.git
$ pip install -e autoencoder/
Or install from PyPI :
$ pip install easyvae
- Optionally, run mnist_test.py to see it in action on the MNIST dataset.
$ cd examples
$ py mnist_test.py
Training
Instatiate an ClassicalAutoencoder or VariationalAutoencoder object :
from easyvae.autoencoder import ClassicalAutoencoder, VariationalAutoencoder
from easyvae.activations import LeakyReLU
autoencoder = ClassicalAutoencoder(
[768, 64, 16],
[16, 64, 768],
0.01,
LeakyReLU()
)
# or
autoencoder = VariationalAutoencoder(
[768, 64, 16],
[16, 64, 768],
0.01,
LeakyReLU()
)
And then via the train_dataset method to train over a dataset :
autoencoder.train_dataset(data)
Or via the train method to input each data points iteratively :
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
Use your Autoencoder object with the encode, decode, forward methods like so :
example = ...
code = autoencoder.encode(example)
output = autoencoder.decode(code)
output, code = autoencoder.forward(example)
Languages
Python
100%