cd RSAM
pip install -r requirements.txt
The CIFAR10 and CIFAR100 datasets will be auto downloaded when running the code. The TinyImageNet dataset can be prepared with bash load_tiny_imagenet.sh
Firstly run standard SGD or Adam:
python3 main_one.py --optimizer sgd --dataset CIFAR10 --arch resnet18 --gpu 0 --batch_size 128 --lr_policy warmup_cosine_lr --lr 0.1 --wd 0.0001 --regularization L2 --lmbda 0.0 --epochs 200 --warmup 10 --use_fix False --aug True --use_full_data True --init None
Then compute the generalization gap and Rényi sharpness
python3 compute_one.py --aug False --dataset CIFAR10 --arch resnet18 --gpu 0 --model_path=model_path --use_fix False
python3 compute_power.py --aug False --dataset CIFAR10 --arch resnet18 --gpu 0 --model_path=model_path --use_fix False
python3 compute_renyi.py --aug False --dataset CIFAR10 --arch resnet18 --gpu 0 --model_path=model_path --use_fix False
python3 train_sam.py --arch resnet20 --init none --dataset CIFAR10 --optimizer sgd --aug True --use_fix False --gpu 0 --epochs 200 --batch_size 128 --lr 0.1 --wd 0.0005 --lmbda 0 --renyi false --lr_policy cosine_lr --sam_mode NEWRSAM --renyi_s 0.65 --alpha 1.2 --plain_epoch 5
We’re currently simplifying the codebase and making updates. Thanks for your patience. If you need the original runnable code urgently, please email me at [email protected]