When we finalize this repository, we find a critical bug in the testing script of sharp-maml. I will update the repository with the current results shortly. Thanks for your interest on our work and patience.
- Python: 3.9.7
- Pytorch: 1.11.0
Standard baseline 4-layer convolutional NN model comprising of 4 modules with a 3 × 3 convolutions with 64 filters followed by batch normalization, a ReLU non-linearity, and a 2 × 2 max-pooling.
To run Sharp-MAML (lower) use:
python3 train_lower.py /path/to/data --num-shots 1 --num-ways 5 --download --use-cuda
To run Sharp-MAML (upper) use:
python3 train_both.py /path/to/data --num-shots 1 --num-ways 5 --download --use-cuda
Note: In the train_both.py file, set the argument 'SAM_lower' as 'False' to use only Sharp-MAML (upper)
To run Sharp-MAML (both) use:
python3 train_both.py /path/to/data --num-shots 1 --num-ways 5 --download --use-cuda
Note: In the train_both.py file, set the argument 'SAM_lower' as 'True' to use Sharp-MAML (both)
After training, the trained model file is saved in the '/save_results' folder in '.th' file format using the model’s state_dict with the torch.save() function. The saved model can be loaded and used to test the model on the held-out testing dataset using model.load_state_dict(torch.load(PATH)).
Momin Abbas, Quan Xiao, Lisha Chen, Pin-Yu Chen, Tianyi Chen. Sharp-MAML: Sharpness-Aware Model-Agnostic Meta Learning. [ArXiv]
If you use this code, please cite the following reference:
@inproceedings{abbas2022,
author = {Momin Abbas and Quan Xiao and Lisha Chen and Pin-Yu Chen and Tianyi Chen},
title = {Sharp-MAML: Sharpness-Aware Model-Agnostic Meta Learning},
year = {2022},
booktitle = {Proceedings of International Conference on Machine Learning},
address = {Maryland, MD},
}