This project studies sparse neural network training on CIFAR-10 with a ResNet-20 style model. It compares fixed-masking and dynamic sparsity strategies under multiple sparsity levels and optimizers to understand when sparse training can preserve accuracy.
Modern neural networks are often heavily over-parameterized. The core question in this project is whether a model can keep competitive performance while training with substantially fewer active weights.
We evaluate three sparsity strategies:
- Static Sparse Training: a fixed binary mask applied at initialization and kept unchanged throughout training.
- Sparse Evolutionary Training (SET): sparse connections are randomly pruned and regrown over time.
- RigL (Rigging the Lottery): sparse connections are updated using gradient information to regrow important weights.
Each method is evaluated at 90%, 95%, and 98% sparsity with both SGD with momentum and Adam.
.
├── 00_baseline.ipynb # Dense baseline experiment
├── 01_task_1.ipynb # Static sparse training
├── 01_task_2.ipynb # SET dynamic sparsity
├── 01_task_3.ipynb # RigL dynamic sparsity
├── Final_Paper.pdf # Final report
├── models.py # ResNetCIFAR model and residual blocks
├── data/
│ └── cifar-10-batches-py/ # CIFAR-10 data files
├── results/ # Saved experiment artifacts
├── img/ # Generated figures used in the report
└── README.md
A binary mask is sampled once at initialization and remains fixed for the full training run. This gives a simple baseline for sparse learning.
SET maintains a sparse network by removing connections and randomly regrowing new ones during training.
RigL also maintains constant sparsity, but regrowth is guided by gradient magnitude so the model can reallocate capacity more effectively.
- Static sparsity is a strong baseline and remains surprisingly competitive at moderate sparsity.
- RigL generally performs better than SET, showing the value of gradient-guided regrowth.
- Optimizer choice matters: Adam is typically more stable for dynamic sparsity, while SGD is stronger in some static settings.
- Performance drops sharply at 98% sparsity, suggesting the model begins to lose too much capacity.
- Python 3.8+
- PyTorch
- torchvision
- matplotlib
- numpy
Install the core dependencies with:
pip install torch torchvision matplotlib numpyRun the notebooks in sequence:
00_baseline.ipynbfor the dense baseline.01_task_1.ipynbfor static sparse training.01_task_2.ipynbfor SET.01_task_3.ipynbfor RigL.
Each notebook trains the model, logs accuracy and loss, and generates plots or artifacts used in the final report.
- Architecture:
ResNetCIFAR, a CIFAR-style ResNet-20 variant defined inmodels.py. - Dataset: CIFAR-10.
- Data augmentation: not used.
- Training epochs: 15.
- Batch size: 128.
- Optimizers:
- SGD with momentum 0.9 and learning rate 0.1.
- Adam with learning rate 0.001.
The repository includes the following generated outputs:
- Training and test accuracy curves.
- Final accuracy versus sparsity plots.
- Weight/kernel visualizations.
- Connectivity evolution plots for RigL.
- Saved run artifacts in
results/.
- The repository follows a
task_n_*naming pattern for saved artifacts inresults/andimg/. 00_baseline.ipynbimportsResNetCIFARfrommodels.pyinstead of redefining the model in the notebook.
- Ammy Lin
- Tonantzin Real Rojas
- Anvita Suresh
This repository was created for ECE 685D/CS 675D: Introduction to Deep Learning at Duke University with Professor Vahid Tarokh.