ModernVGG-BN CIFAR-10 Image Classification (PyTorch)
Project Overview
This project implements a VGG-style Convolutional Neural Network for image classification on CIFAR-10 using PyTorch.
The model is trained from scratch with modern deep learning techniques including:
- Mixed Precision Training (AMP)
- AdamW optimizer
- Cosine Annealing Learning Rate Scheduler
- Gradient Clipping
- Early Stopping
- Batch Normalization throughout the network
Dataset
- CIFAR-10 dataset
- 10 classes: airplane, automobile, bird, cat, deer, dog, frog, horse, ship, truck
- 32Γ32 RGB images
Model Architecture
Feature Extractor (VGG-style CNN)
64 β 128 β 256 β 512 β 512
Each block: Conv2D β BatchNorm β ReLU β Conv2D β BatchNorm β ReLU β MaxPool
Classifier Head
- AdaptiveAvgPool2D (1Γ1)
- Flatten
- Linear (512 β 256)
- BatchNorm1D
- ReLU
- Dropout (0.2)
- Linear (256 β 10)
Training Pipeline
Each epoch includes:
- Forward pass
- Loss computation
- Backpropagation
- Gradient clipping
- Optimizer step (AdamW)
- Scheduler step (CosineAnnealingLR)
- Validation
- Metric logging
- Best model checkpoint saving
- Early stopping monitoring
Regularization Techniques
- Batch Normalization
- Dropout (0.2)
- Gradient Clipping
- Early Stopping
Results
- CIFAR-10.1 Accuracy: 78.95%
- Strong generalization on unseen dataset (CIFAR-10.1)
- Most confusion between:
- automobile β truck
- cat β dog
Inference Pipeline
Image β Resize β Normalize β Model β Softmax β Prediction
Outputs:
- Predicted class
- Confidence score
- Top-5 probabilities
Model Saving Format
torch.save({
"epoch": epoch,
"model_state_dict": model.state_dict(),
"optimizer_state_dict": optimizer.state_dict(),
"scheduler_state_dict": scheduler.state_dict(),
"scaler_state_dict": scaler.state_dict(),
"best_acc": best_acc
}, "best_model.pth")
Evaluation results
- train_accuracy on CIFAR-10self-reported99.950
- train_loss on CIFAR-10self-reported0.001
- val_accuracy on CIFAR-10self-reported89.830
- val_loss on CIFAR-10self-reported0.346
- test_accuracy on CIFAR-10.1self-reported78.950
- test_loss on CIFAR-10.1self-reported0.682