Downloads · 30 days
0
DineshSundaram/resnet34-cifar100
resnet34-cifar100 is a machine learning model from DineshSundaram. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
A comprehensive implementation of ResNet-34 for CIFAR-100 classification, optimized to achieve 83% accuracy in 50 epochs with fewer than 400,000 trainable parameters.
Downloads · 30 days
0
Access
Public
Updated Oct 11, 2025
Repo size
2.4 MB
Likes
0
Public
Click a slice to open those files.
.pth2.4 MB · 99%
From the Hugging Face model README
A comprehensive implementation of ResNet-34 for CIFAR-100 classification, optimized to achieve 83% accuracy in 50 epochs with fewer than 400,000 trainable parameters.
Our implementation uses a modified ResNet-34 architecture optimized for CIFAR-100:
| Layer | Input Shape | Kernel | Stride | Padding | Output Shape | Receptive Field | Parameters |
|---|---|---|---|---|---|---|---|
| Conv1 | (3,32,32) | 3×3 | 1 | 1 | (32,32,32) | 3 | 864 |
| Layer1.Block1 | (32,32,32) | 3×3 | 1 | 1 | (32,32,32) | 5 | ~9K |
| Layer1.Block2 | (32,32,32) | 3×3 | 1 | 1 | (32,32,32) | 7 | ~9K |
| Layer1.Block3 | (32,32,32) | 3×3 | 1 | 1 | (32,32,32) | 9 | ~9K |
| Layer2.Block1 | (32,32,32) | 3×3 | 2 | 1 | (64,16,16) | 11 | ~18K |
| Layer2.Block2 | (64,16,16) | 3×3 | 1 | 1 | (64,16,16) | 13 | ~36K |
| Layer2.Block3 | (64,16,16) | 3×3 | 1 | 1 | (64,16,16) | 15 | ~36K |
| Layer2.Block4 | (64,16,16) | 3×3 | 1 | 1 | (64,16,16) | 17 | ~36K |
| Layer3.Block1 | (64,16,16) | 3×3 | 2 | 1 | (128,8,8) | 19 | ~72K |
| Layer3.Block2-6 | (128,8,8) | 3×3 | 1 | 1 | (128,8,8) | 21-29 | ~144K each |
| Layer4.Block1 | (128,8,8) | 3×3 | 2 | 1 | (256,4,4) | 31 | ~288K |
| Layer4.Block2-3 | (256,4,4) | 3×3 | 1 | 1 | (256,4,4) | 33-35 | ~576K each |
| AvgPool | (256,4,4) | 4×4 | 1 | 0 | (256,1,1) | 35 | 0 |
| FC | (256,) | - | - | - | (100,) | - | 25.6K |
git clone <repository-url>
cd resnet-34-cifar-100
pip install -r requirements.txt
python main.py --dry-run
# Train with default settings
python main.py
# Train with custom parameters
python main.py --epochs 50 --batch-size 128 --learning-rate 0.1
# Use Adam optimizer instead of SGD
python main.py --optimizer Adam --learning-rate 0.001
# Disable depthwise separable convolutions
python main.py --no-depthwise-separable
# Custom output directory
python main.py --output-dir ./my_results
# Skip GradCAM analysis
python main.py --no-gradcam
# Resume from checkpoint
python main.py --resume ./outputs/best_model.pth
| Argument | Default | Description |
|---|---|---|
--batch-size | 128 | Training batch size |
--epochs | 50 | Number of training epochs |
--learning-rate | 0.1 | Initial learning rate |
--optimizer | SGD | Optimizer (SGD/Adam) |
--max-lr | 0.1 | Maximum LR for OneCycleLR |
--weight-decay | 5e-4 | Weight decay regularization |
--device | auto | Device (auto/cuda/cpu) |
--output-dir | ./outputs | Output directory |
--gradcam-samples | 5 | Number of GradCAM samples |
--dry-run | False | Setup without training |
The implementation generates comprehensive visualizations:
resnet-34-cifar-100/
├── main.py # Main entry point
├── data_loader.py # Data loading and augmentation
├── model.py # ResNet-34 architecture
├── train.py # Training loop and optimization
├── gradcam.py # GradCAM visualization
├── output.py # Results visualization
├── utils.py # Utility functions
├── requirements.txt # Dependencies
├── README.md # This file
└── outputs/ # Generated results
├── best_model.pth # Best model checkpoint
├── training_curves.png
├── optimization_impact.png
├── training_results_summary.json
└── gradcam_analysis/
├── misclassified_sample_1.png
├── misclassified_sample_2.png
└── ...
MODEL_CONFIG = {
'num_classes': 100,
'max_parameters': 400000,
'target_accuracy': 0.83,
'architecture': {
'channels': [32, 64, 128, 256],
'blocks': [3, 4, 6, 3],
'use_depthwise_separable': True
}
}
TRAINING_CONFIG = {
'epochs': 50,
'learning_rate': 0.1,
'weight_decay': 5e-4,
'momentum': 0.9,
'optimizer': 'SGD',
'scheduler': 'OneCycleLR',
'max_lr': 0.1,
'pct_start': 0.3,
'grad_clip_norm': 1.0
}
# Reduce batch size
python main.py --batch-size 64
# Use CPU instead
python main.py --device cpu
# Increase number of workers
python main.py --num-workers 8
# Use mixed precision (if supported)
# Add --fp16 flag when implemented
# Try different learning rate
python main.py --learning-rate 0.05
# Use Adam optimizer
python main.py --optimizer Adam --learning-rate 0.001
# Increase weight decay
python main.py --weight-decay 1e-3
# Disable depthwise separable convolutions
python main.py --no-depthwise-separable
# This will increase parameters but may improve accuracy
Monitor training progress with:
# Check GPU usage
nvidia-smi
# Monitor training logs
tail -f outputs/training.log
# Check parameter count
python -c "from model import create_resnet34; from utils import count_parameters; model = create_resnet34(); print(f'Parameters: {count_parameters(model)[\"trainable_parameters\"]:,}')"
Our implementation uses depthwise separable convolutions to reduce parameters:
The learning rate follows a specific schedule:
GradCAM generates attention maps by:
git checkout -b feature/amazing-feature)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)This project is licensed under the MIT License - see the LICENSE file for details.
For questions and support:
Happy Training! 🚀