In this repository, I create a simple generator and discriminator to generate new MNIST images.
The Generator and the Discriminator are both Linear models, a brief overview of how the models look are given further down
the readme. In this repostitory, I generate mew images of the classic MNIST datasets, which include
- KMNIST
- MNIST
- Fashion MNIST
Pretrained models for all the datasets are made available in this repository.
Further, one can even train their own Generator and Discriminator using just one command with the help of this repository.
- Clone the repo and cd into it
git clone https://github.com/iArunava/MNIST-GAN.git
cd MNIST-GAN/
- Start Training
python3 init.py --mode train --dataset kmnist
- Predict using the saved pretrained models.
Note: the saved models are treated as checkpoint files, which has the
state_dict
key.
python3 init.py --mode predict --dataset kmnist
or
python3 init.py --mode predict -dpath /path/to/discriminator.pth -gpath /path/to/generator.pth
Discriminator(
(linear1): Linear(in_features=784, out_features=512, bias=True)
(linear2): Linear(in_features=512, out_features=256, bias=True)
(linear3): Linear(in_features=256, out_features=128, bias=True)
(linear4): Linear(in_features=128, out_features=1, bias=True)
(dropout): Dropout(p=0.3)
)
Generator(
(fc1): Linear(in_features=100, out_features=32, bias=True)
(fc2): Linear(in_features=32, out_features=64, bias=True)
(fc3): Linear(in_features=64, out_features=128, bias=True)
(fc4): Linear(in_features=128, out_features=784, bias=True)
(dropout): Dropout(p=0.3)
)
The code in this repository is made available for free. Feel free to fork this repository and start playing with it.