This is the pytorch implementation of the paper "Contrastive Supervised Learning on Domain Generalization and Application to Data Corruption".
- A Python install version 3.7
- A PyTorch and torchvision installation version 1.7.0 and 0.8.1, respectively.
- The caffe model we used for AlexNet. Once downloaded, move it into ./alexnet_caffe.pth.tar
- PACS dataset
- OfficeHome dataset
- CIFAR-10-C
You can train the model from scratch :
- cd MDG
- python main.py --data_dir ./data_dir --model AlexNet --datasets PACS
- data_dir: the dataset directory
- model: AlexNet or ResNet18
- datasets: PACS or OfficeHome
You can train the model from scratch :
- cd SDG
- python main.py --data_dir ./cifar10_dir --target_dir ./cifar10C_dir --file_name acc.csv
- data_dir: the dataset directory for cifar10
- target_dir: the dataset directory for cifar10-C
- file_name: the name of file storing the test accuracy