uday9k commited on
Commit
0bb92d3
·
verified ·
1 Parent(s): dc34ad7

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +149 -0
README.md CHANGED
@@ -1,3 +1,152 @@
1
  ---
 
 
 
 
 
 
 
2
  license: mit
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language: en
3
+ tags:
4
+ - vae
5
+ - generative-model
6
+ - pytorch
7
+ - swiss-roll
8
+ - unsupervised-learning
9
  license: mit
10
+ datasets:
11
+ - make_swiss_roll
12
  ---
13
+
14
+ # VAE Model for Swiss Roll
15
+
16
+ This is a Variational Autoencoder (VAE) model trained on the Swiss Roll dataset.
17
+
18
+ ## Model Description
19
+
20
+ This repository contains a complete implementation of a Variational Autoencoder (VAE) trained on the Swiss Roll 2D manifold dataset. The model learns to encode 2D points from the Swiss Roll into a lower-dimensional latent space and decode them back, enabling both dimensionality reduction and generation of new points that lie on the Swiss Roll manifold.
21
+
22
+ The architecture is based on the implementation outlined in **Auto-Encoding Variational Bayes by Diederik et al., 2022**
23
+
24
+ ### Architecture Details
25
+
26
+ - **Model Type**: Variational Autoencoder (VAE)
27
+ - **Framework**: PyTorch
28
+ - **Input**: 2-dimensional points from Swiss Roll (x, z coordinates after projection)
29
+ - **Latent Space**: 2 dimensions
30
+ - **Encoder and Decoder Layers**: 2
31
+ - **Encoder and Decoder Hidden Units**: 96 → 48 (encoder), 96 → 48 (decoder)
32
+ - **Total Parameters**: 15,994
33
+ - **Data type:** Binary/Continous (automatically detected)
34
+ - **Current Implementation:** Continous (un-normalised)
35
+
36
+ ### Key Components
37
+
38
+ 1. **Encoder Network**: Maps input images to latent distribution parameters (μ, σ²)
39
+ 2. **Reparameterization Trick**: Enables differentiable sampling from the latent distribution
40
+ 3. **Decoder Network**: Reconstructs images from latent space samples
41
+ 4. **Loss Function**: Combines reconstruction loss ELBO (Bernoulli: binary cross-entropy, Gaussian: negative log-likelihood) + KL divergence
42
+
43
+ ## Training Details
44
+
45
+ - **Dataset**: Swiss Roll (10,000 points generated using scikit-learn's make_swiss_roll)
46
+ - **Train/Test Split**: 80/20
47
+ - **Batch Size**: 128
48
+ - **Epochs**: 150
49
+ - **Optimizer**: Adam
50
+ - **Learning Rate**: 1e-3
51
+ - **Gamma**: 1e-1
52
+
53
+ ## Model Performance
54
+
55
+ ### Metrics
56
+ - **Final Training Loss**: ~6.16
57
+ - **Reconstruction Loss**: ~3.42
58
+ - **KL Divergence**: ~2.74
59
+
60
+ - **Final Validation Loss**: ~5.94
61
+ - **Reconstruction Loss**: ~3.23
62
+ - **KL Divergence**: ~2.71
63
+
64
+ ### Capabilities
65
+ - ✅ High-quality reconstruction of Swiss Roll points
66
+ - ✅ Smooth latent space interpolation
67
+ - ✅ Generation of new points along the Swiss Roll manifold
68
+ - ✅ Well-organized latent space capturing the underlying manifold structure
69
+
70
+
71
+ ## Usage
72
+
73
+ ### Using Transformers
74
+
75
+ ```python
76
+ from transformers import AutoModel
77
+ import torch
78
+ import torchvision.transforms as transforms
79
+
80
+ # Load model
81
+ model = AutoModel.from_pretrained("uday9k/SwissRoll_VAE")
82
+
83
+ # Generate samples
84
+ with torch.no_grad():
85
+ z = torch.randn(1, 20) # Sample from prior
86
+ generated = model.generate(z=z)
87
+ ```
88
+
89
+ ### Visualizations Available
90
+
91
+ 1. **Latent Space Visualization**: 2D projection of the 2D latent space showing manifold structure
92
+ 2. **Reconstructions**: Original vs. reconstructed Swiss Roll points
93
+ 3. **Generated Samples**: New digits sampled from the latent space
94
+ 4. **Interpolations**: Smooth transitions between different regions of the Swiss Roll
95
+ 5. **Training Curves**: Loss components over training epochs
96
+
97
+ ## Files and Outputs
98
+
99
+ - `SwissRoll_VAE_Train.ipynb`: Complete implementation with training and visualization
100
+ - `customVAE_model.pth`: Trained model weights
101
+ - `generated_samples`: Scatter plot of generated samples as part of notebook
102
+ - `latent_space_visualization`: 2D latent space plot as part of notebook
103
+ - `reconstruction_comparison`: Original vs reconstructed images as part of notebook
104
+ - `latent_interpolation`: Interpolation between points as part of notebook
105
+ - `comprehensive_training_curves`: Training loss curves as part of notebook
106
+
107
+ ## Applications
108
+
109
+ This VAE implementation can be used for:
110
+
111
+ - **Generative Modeling**: Create new points lying on the Swiss Roll manifold
112
+ - **Dimensionality Reduction**: Compress 2D points to 2D latent representations
113
+ - **Manifold Learning**: Learn the underlying structure of the Swiss Roll data
114
+ - **Interpolation**: Generate smooth transitions between points on the manifold
115
+ - **Educational Purposes**: Understand VAE concepts and implementation
116
+
117
+ ## Research and Educational Value
118
+
119
+ This implementation serves as an excellent educational resource for:
120
+
121
+ - Understanding Variational Autoencoders theory and practice
122
+ - Visualizing how VAEs learn manifold structures
123
+ - Learning PyTorch implementation techniques
124
+ - Exploring latent space representations on simple data
125
+ - Studying the balance between reconstruction and regularization
126
+
127
+ ## Citation
128
+
129
+ If you use this implementation in your research or projects, please cite:
130
+
131
+ ```bibtex
132
+ @misc{vae_mnist_implementation,
133
+ title={Variational Autoencoder Implementation for Swiss Roll},
134
+ author={Uday Jain},
135
+ year={2026},
136
+ url={https://huggingface.co/uday9k/SwissRoll_VAE}
137
+ }
138
+ ```
139
+
140
+ ## License
141
+
142
+ This project is licensed under the MIT License - see the LICENSE file for details.
143
+
144
+ ## Additional Resources
145
+
146
+ - **GitHub Repository**: [Profile](https://github.com/SpikeStriker/)
147
+
148
+ ---
149
+
150
+ **Tags**: deep-learning, generative-ai, pytorch, vae, swiss-roll, unsupervised-learning
151
+
152
+ **Model Card Authors**: Uday Jain