Authors: Samuel Schapiro, Han Zhao
This is the official implementation for "Weight-Shift Regularized Sharpness-Aware Minimization for Gradual Domain Adaptation". It is largely based on the code from the paper "Gradual Domain Adaptation: Theory and Algorithms," and the ICML 2022 paper "Understanding gradual domain adaptation: Improved analysis, optimal path and beyond".
TO-DO: Insert table/figure with results
git clone https://github.com/samjschapiro/SAM-GDA.git
cd SAM-GDA
pip install -r requirements.txt
The covertype dataset can be downloaded from: https://archive.ics.uci.edu/dataset/31/covertype.
The portraits dataset can be downloaded from here. We follow the same data preprocessing procedure from https://github.com/p-lambda/gradual_domain_adaptation. Namely after downloading, extract the tar file, and copy the "M" and "F" folders inside a folder called dataset_32x32 inside the current folder. Then run "python create_dataset.py".
To run experiments, follow the following syntax.
python experiments.py --dataset color_mnist --intermediate-domains 1 --opt-name sam
Arguments:
-
datasetcan be selected from[mnist, portraits, covtype, color_mnist] -
optnamecan be selected from[sgd, adam, sam, ssam, asam, fsam, esam] -
base-optcan be selected from[sgd, adam] -
intermediate-domainsis the number of intermediate domains$T$ -
rotation-anglecan be any integer in[0, 359] -
source-epochsis the number of epochs to use for training on the source domain$t = 0$ -
intermediate-epochsis the number of epochs to use for training on intermediate domains$t = 1, 2, \dots, T$ -
batch-sizeis the batch size for training -
lris the learning rate -
num-workersis the number of workers for parallelization
This repository is largely based on work done by Haoxiang Wang, Yifei He, Bo Li, and Han Zhao:
@misc{he2023gradual,
title={Gradual Domain Adaptation: Theory and Algorithms},
author={Yifei He and Haoxiang Wang and Bo Li and Han Zhao},
year={2023},
eprint={2310.13852},
archivePrefix={arXiv},
primaryClass={cs.LG}
}
@inproceedings{wang2022understanding,
title={Understanding gradual domain adaptation: Improved analysis, optimal path and beyond},
author={Wang, Haoxiang and Li, Bo and Zhao, Han},
booktitle={International Conference on Machine Learning},
pages={22784--22801},
year={2022},
organization={PMLR}
}
