meta-Domain Specific-Domain Invariant (mDSDI)
Source code implementation for the paper:
Manh-Ha Bui, Toan Tran, Anh Tuan Tran, Dinh Phung. "Exploiting Domain-Specific Features to Enhance Domain Generalization". Advances in Neural Information Processing Systems (NeurIPS | 2021).
Guideline
To prepare:
Install prerequisite packages:
python -m pip install -r requirements.txt
Download and unzip the datasets:
bash setup.sh
To run experiments:
Run with five different seeds:
for i in {1..3}; do
taskset -c <cpu_index> python main.py --config <config_path> --exp_idx $i --gpu_idx <gpu_index>
done
where the parameters are the following:
<cpu_index>
: CPU index. E.g.,<cpu_index> = "1"
<config_path>
: path stored configuration hyper-parameters. E.g.,<config_path> = "algorithms/mDSDI/configs/PACS_photo.json"
<gpu_index>
: GPU index. E.g.,<gpu_index> = "0"
Note: Select different settings by editing in /configs/..json
, logging results are stored in /results/logs/
To visualize objective functions:
tensorboard --logdir <logdir>
where <logdir>
: absolute path stored TensorBoard results. E.g., <logdir> = "/home/ubuntu/mDSDI/algorithms/mDSDI/results/tensorboards/PACS_photo_1"
To plot feature representations:
python utils/tSNE_plot.py --plotdir <plotdir>
where <plotdir>
: path stored results to plot. E.g., <plotdir> = "algorithms/mDSDI/results/plots/PACS_photo_1/"
Note: Results are stored in /results/plots/
"DomainBed, Ishaan and David, 2021" library:
To run oncd DomainBed/
python -m domainbed.scripts.train --data_dir=../data/ --algorithm MDSDI --dataset <dataset_name> --test_env <env_idx>
where the parameters are the following:
<dataset_name>
: name of 5 benchmark datasets, including: RotatedMNIST | VLCS | OfficeHome | PACS | DomainNet. E.g.,<dataset_name> = PACS
<test_env>
: index of the target domain. E.g.,<dataset_name> = 0
Note: Results are stored in DomainBed/results/train_output/out.txt