An autoencoder is a type of neural network that learns to compress (encode) input data into a lower-dimensional latent space and then reconstruct (decode) the input from this compressed representation.
It is made up of two main parts:
- Encoder: Reduces input dimensions (compression)
- Decoder: Reconstructs the original data from encoded features
Given input data x, the encoder function f(x) maps it to a latent representation z:
z = f(x) = encoder(x)
The decoder then attempts to reconstruct x as:
x' = g(z) = decoder(z)
The model is trained by minimizing the reconstruction loss, commonly Mean Squared Error (MSE):
Loss = ||x - x'||²
- Anomaly Detection: Unusual data has high reconstruction error.
- Dimensionality Reduction: Autoencoders can serve as a non-linear alternative to PCA.
- Clustering: The latent space learned can be used for unsupervised clustering.
- Feature Extraction: Compressed latent vectors can be used as inputs for downstream models.
File/Folder | Description |
---|---|
code.ipynb |
Jupyter Notebook to train and visualize the Fully Connected Autoencoder |
requirements.txt |
Contains all dependencies to ensure reproducibility |
data/ |
Folder that stores MNIST dataset (downloaded automatically) |
-
Create a virtual environment (Windows)
python -m venv venv venv\Scripts\activate
-
Install the dependencies
pip install -r requirements.txt
-
Run the Jupyter Notebook
jupyter notebook code.ipynb
- Python 3.8+
- PyTorch
- torchvision
- matplotlib
- scikit-learn
- jupyter (if running
.ipynb
locally)
All required libraries are listed in requirements.txt
and pre-installed in the Docker image.
Shakeel Ahmed