This project studies whether Knowledge Distillation (KD) improves robustness for CIFAR-100 image classification under domain shift.
Models:
- Teacher: ResNet-34
- Baseline student: ResNet-18
- KD student: ResNet-18 trained from teacher soft targets
project/
data/
data_loader.py
corruptions.py
models/
training/
evaluation/
outputs/
python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txtIf test_model.py fails because torch is missing, activate the environment first and reinstall dependencies:
.venv\Scripts\activate
pip install -r requirements.txt
python test_model.pyCheck that the ResNet teacher and student can process CIFAR-sized inputs:
python test_model.pyCheck that CIFAR-100 loads correctly:
python test_data.pyTrain the teacher:
python -m training.train_teacherTrain the baseline student:
python -m training.train_baselineTrain the KD student:
python -m training.train_kdThe training scripts now use 100 epochs by default and save checkpoints under outputs/checkpoints/.
Evaluate all available checkpoints on clean CIFAR-100 and corrupted CIFAR-100:
python -m evaluation.evaluateThe evaluation covers:
- clean test data
- gaussian noise
- blur
- brightness shift
- contrast shift
- severities 1, 3, and 5
Missing checkpoints are skipped automatically. Results are saved to:
outputs/results.json
Generate comparison plots after running evaluation:
python -m evaluation.plot_resultsFigures are saved under:
outputs/figures/
- Full training is much faster with GPU.
- Accuracy from short or interrupted runs is only useful for pipeline testing, not final conclusions.
- Data files and model outputs are ignored by git; source files for loaders and corruptions are tracked.