Code for the paper Enhancing Compositinal Generalization via Compositional Feature Alignment
CREDITS: Our code is heavily based on https://github.com/mlfoundations/wise-ft and https://github.com/locuslab/FLYP. We thank the authors for open sourcing their code.
conda create -n cfa python=3.11 anaconda
conda activate cfa
pip install -r requirements.txtWe conducted our experiments on DomainBed and Wilds. Put the datasets under ./cfa/data/.
Our CFA is a two stage finetuning method. To run CFA, fill out all the parameters in the lauching files.
To run Stage-1 of CFA and Linear Probing, fill out the configs in linear_probe_exps.py.
python linear_probes_exps.py # Run Linear Probing CodesTo run Stage-2 of CFA, Finetuning and LP-FT, fill out the configs in launch_exp.py.
python launch_exp.py # Run Finetuning CodesTo perform model interpolation, fill out the configs in interpolate.py.
python interpolate.py # Run WiSE