A hands-on tutorial demonstrating the power and simplicity of Weights & Biases (W&B) for machine learning experiment tracking and visualization. Using Autoencoders and Variational Autoencoders on MNIST as example models, this project showcases how easy it is to set up professional-grade ML monitoring and beautiful visualizations.
- 📊 Effortless Experiment Tracking: See how simple it is to log metrics, hyperparameters, and model performance
- 🎨 Beautiful Visualizations: Generate stunning 2D latent space plots with just a few lines of code
- 📈 Real-time Monitoring: Watch your models train with live loss curves and metrics
- 🔍 Model Introspection: Track gradients, parameters, and model architecture automatically
- 💾 Automatic Logging: Save plots, checkpoints, and metadata without manual file management
- 🚀 Zero Configuration: Get professional ML tracking running in minutes, not hours
-
Clone the repository:
git clone https://github.com/GauravR1206/AI_Summer_School.git cd AI_Summer_School -
Install dependencies:
pip install torch torchvision matplotlib wandb datasets kagglehub
-
Set up Weights & Biases (this is the important part! 🎯):
wandb login
This will open your browser to get your W&B API key. Create a free account if you don't have one - it takes 30 seconds!
Once you're set up, these simple commands will show you the magic of W&B:
python train_AE.py --epochs 20 --latent_dim 2python train_VAE.py --epochs 20 --latent_dim 2🎉 That's it! After running either command:
- Your browser will automatically open to your W&B dashboard
- You'll see real-time loss curves updating every epoch
- Beautiful 2D latent space visualizations appear every 5 epochs
- All hyperparameters, model architecture, and metrics are automatically logged
--epochs Number of training epochs (default: 20)
--batch_size Batch size for training (default: 128)
--lr Learning rate (default: 1e-3)
--latent_dim Dimensionality of latent space (default: 2)
--project W&B project name (default: mnist-ae/mnist-vae)
--entity W&B entity/team name (optional)
--data_dir Directory to store MNIST data (default: ./data)
--save_dir Directory to save checkpoints (default: ./checkpoints)
--seed Random seed for reproducibility (default: 42)
AI_Summer_School/
├── 📄 README.md # You are here!
├── 🧠 models.py # Neural network architectures (AE & VAE)
├── 🏃♂️ train_AE.py # Autoencoder training script
├── 🏃♂️ train_VAE.py # Variational Autoencoder training script
├── 📦 pyproject.toml # Project dependencies and metadata
├── 🔒 uv.lock # Dependency lock file
├── 📜 LICENSE # MIT License
├── 📊 data/ # MNIST dataset (auto-downloaded)
├── 💾 checkpoints/ # Model checkpoints (created during training)
└── 📈 wandb/ # Weights & Biases experiment logs
See how simple it is to add professional ML tracking to any project:
import wandb
wandb.init(project="my-awesome-project", config={
"learning_rate": 0.01,
"epochs": 100,
})wandb.log({
"loss": loss.item(),
"accuracy": accuracy,
"epoch": epoch
})fig = plot_latent_space(model, data_loader, device)
wandb.log({"latent_space": wandb.Image(fig)})We use simple neural networks to demonstrate W&B features:
- Simple reconstruction loss tracking
- Basic latent space visualization
- Multiple loss components (BCE + KL divergence)
- More complex metric relationships
Now that you've seen how easy W&B is, here are some exciting ways to extend your learning:
- Add
wandb.init()to any existing training script - Log your metrics with
wandb.log() - Upload plots with
wandb.Image() - Share beautiful experiment results with your team!
-
Can you log the input and images as well like you are logging the latent space?
- Try logging original MNIST images alongside reconstructions
- Compare input vs. output side-by-side in W&B
-
What happens to the latent space as you change the KL weight?
- Experiment with different β values in β-VAE
- Watch how latent space structure changes in real-time
-
How about a model comparison on with different KL weights?
- Run multiple VAE experiments with varying KL weights
- Use W&B's comparison tools to analyze the differences
-
Do you want to train other models?
- Try different architectures (CNNs, ResNets, Transformers)
- Experiment with other datasets (CIFAR-10, CelebA)
- All while maintaining the same beautiful W&B logging!
This project is licensed under the MIT License - see the LICENSE file for details.
- Weights & Biases: For making ML experiment tracking delightfully simple
- PyTorch & MNIST: Perfect tools for demonstrating W&B capabilities
- AI Summer School participants: Happy learning! 🎓
W&B + Your Projects = Professional Results in Minutes