This repo contains the code of the MN911 - Mini-project within our M2 - Multimedia Networking program.
In this work, we train a slightly modified ResNet architecture using different margin-based losses on the CIFAR-10 dataset.
The final report can be found in resources/CNN-project6.pdf.
These commands are used to reproduce the ResNet-18 model we obtained.
Modify all resnet18 to resnet50 to train with a ResNet-50 model.
- With Cross-Entropy Loss:
python train.py resnet18 --dataset cifar10 --model resnet18 --manual_seed 17 --batch_size 256 --epochs 250- With Margin-based Cross-Entropy Losses
(available options for
[loss_name]aresphereface | cosface | arcface | curricularface | adaface):
python train.py resnet18_[loss_name] --dataset cifar10 --model resnet18 --manual_seed 17 --batch_size 256 --epochs 250 --loss [loss_name]For evaluating a trained model, you can run the same train.py script with --eval_only option.
All other training-exclusive parameters will be ignored.
To save visualization of normalized feature space, run the exact training script with --vis option.
This will split the last fully-connected layer in two with the intermediate dimension of 3, which we can then plot.
Note that this visualization method drastically reduce the performance of the model.
The obtained results would look like these:
| CE | AdaFace |
|---|
For trained model, if it was trained using with --vis option, you can enable --eval_only parameter similar to
Evaluating section. For example:
python train.py resnet18_ce_vis --dataset cifar10 --model resnet18 --manual_seed 17 --batch_size 512 --loss ce --resume_from outputs/resnet18_ce_vis/resnet18_250.pth --eval_only --visOtherwise, you would need to extract feature space using the extract_features.py script
and then apply a dimensionality reduction technique (T-SNE, UMAP, etc.) on the saved feature vectors.
Unfortunately, we don't include that code in this repo.
This project was conducted under the supervision of Prof. Dijana Petrovska.
MIT licensed, see LICENSE.txt.

