한국어 버전의 설명은 여기를 참고하시기 바랍니다.
An autoencoder is a model used for manifold learning that extracts meaningful latent variables to compress or reduce the dimensionality of the data through the process of compressing and reconstructing the original data.
In this code, you can find implementations of three types of autoencoders.
For the MNIST dataset, it also provides functionality to visualize the latent variables resulting from the trained model in 2D using t-SNE algorithm.
For an explanation of autoencoders, refer to Autoencoder (오토인코더), and for information on t-SNE and UMAP, refer to t-SNE, UMAP.
- A vanilla autoencoder using
nn.Linear
is implemented.
- A convolutional autoencoder using
nn.Conv2d
andnn.ConvTranspose2d
is implemented. When you want to improve model performance, you can use CAE instead of AE.
- For the two models introduced above, you can train a denoising autoencoder by adding noise to the data.
Denoising autoencoders can be used to extract more meaningful latent variables from the data.
- Base dataset for tutorial is MNIST.
- Custom datasets can also be used by setting the path in the
config/config.yaml
. However, implementing a custom dataloader may require additional coding work insrc/utils/data_utils.py
.
- CPU, GPU, multi-GPU (DDP), MPS (for Mac and torch>=1.12.0)
python3 src/run/train.py --config config/config.yaml --mode train
This repository is structured as follows.
├── configs <- Folder for storing config files
│ └── *.yaml
│
└── src
├── models
| ├── autoencoder.py <- Valilla autoencoder model file
| └── conv_autoencoder.py <- Convolutional autoencoder model file
|
├── run
| ├── train.py <- Training execution file
| ├── tsne_test.py <- Trained model t-SNE visualization execuation file
| └── validation.py <- Trained model evaulation execution file
|
├── tools
| ├── model_manager.py
| └── training_logger.py <- Training logger class file
|
├── trainer
| ├── build.py <- Codes for initializing dataset, dataloader, etc.
| └── trainer.py <- Class for training, evaluating, and visualizing with t-SNE
|
└── uitls
├── __init__.py <- File for initializing the logger, versioning, etc.
├── data_utils.py <- File defining the custom dataset dataloader
├── filesys_utils.py
└── training_utils.py
Please follow the steps below to train the autoencoder.