Let's start by installing all the dependencies.
pip3 install -r requirement.txtWe employ cifar10_RT_ER.py and cifar10_JTDMoE.py to adversarially train an MoE model and a dual-model on the CIFAR-10 dataset using Resnet18. Similarly, we use tinyimagenet_RT_ER.py and tinyimagenet_JTDMoE.py for adversarial training of an MoE model and a dual-model on the TinyImageNet dataset using ViT-small. Below, we outline the key arguments and their usage.
--netSpecifies the model architecture used for training.--resumeDefines the path to the checkpoint for evaluation or resuming training.--sizeSets the size of the input image.--betaControls the proportion of expert contributions in the model.--alphaAdjusts the contribution of the robust model within the dual-model.
Please use the file AutoAttack.py to evaluate the model using AutoAttack.
To train an MoE on CIFAR-10 dataset using RT-ER method:
python3 cifar10_RT_ER.py --net res18_moeTo joint-training a dual-model on CIFAR-10 dataset using JTDMoE method:
python3 cifar10_JTDMoE.py --net dual_model_res18To train an MoE on TinyImageNet dataset using RT-ER method:
python3 tinyimagenet_RT_ER.py --net vit_moeTo joint-training a dual-model on TinyImageNet dataset using JTDMoE method:
python3 tinyimagenet_JTDMoE.py --net dual_model_vitTo obtain the original TinyImageNet dataset, please run the following scripts:
cd data/tiny_imagenet
wget http://cs231n.stanford.edu/tiny-imagenet-200.zip
unzip -qq 'tiny-imagenet-200.zip'
rm tiny-imagenet-200.zip