Skip to content

#ICML2022 Experimental codes of "On the Surrogate Gap between Contrastive and Supervised Losses"

License

Notifications You must be signed in to change notification settings

nzw0301/gap-contrastive-and-supervised-losses

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

System-related versions

  • python: 3.6.8
  • CUDA: 11.2
  • cudnn: 8005

Create an experimental environment

pip install -r requirements.txt

git clone git@github.com:NVIDIA/apex.git
cd apex
git checkout 54b93919aadc117cbab1fe5a2af4664bb9842928
pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./

Install an optional library for efficient experiments.

# Install gnu-parallel from source.
wget https://ftp.gnu.org/gnu/parallel/parallel-20210622.tar.bz2
tar -jxvf parallel-20210622.tar.bz2
cd parallel-20210622
./configure --prefix=~/bin
make
make install

Execute training code

Note that this repo manages the experimental results by using wandb. Please replace INPUT_YOUR_ENTITY with your wandb username in codes that you would like to run.

Evaluation

Preparation

Please run ./code/notebooks/extract_eval_weights_from_wandb.ipynb.

Perform evaluation to draw plots

  • Vision: Please run the {cifar10,cifar100}/mean_eval.sh, {cifar10,cifar100}/linear_eval.sh and {cifar10,cifar100}/contrastive_eval.sh scripts under code/jobs/vision directory.
  • Language: Please run the mean_eval.sh, linear_eval.sh and contrastive_eval.sh scripts under code/jobs/language/wiki3029 directory.

Create plots

Please run the following notebooks to generate plots

Synthetic experiments

Note that the scripts for Figures 5 and 6 require the results generated by code/jobs/toy/circle.sh.

Real benchmark datasets


Note:: this codebase tracks experiments using Weights & Biases, but the default wandb might cause hanging at the beginning of training of distributed training code. To avoid this, please set an environment variable as follows:

WANDB_START_METHOD="thread"

References

@inproceedings{BNN2022,
    title = {{On the Surrogate Gap between Contrastive and Supervised Losses}},
    author = {Bao, Han and Nagano, Yoshihiro and Nozawa, Kento},
    year = {2022},
    booktitle = {ICML},
    pages = {1585--1606},
}

Related resource

About

#ICML2022 Experimental codes of "On the Surrogate Gap between Contrastive and Supervised Losses"

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published