Home

Awesome

Debiased Contrastive Learning

<p align='center'> <img src='https://github.com/chingyaoc/DCL/blob/master/misc/fig1.png?raw=true' width='500'/> </p>

A prominent technique for self-supervised representation learning has been to contrast semantically similar and dissimilar pairs of samples. Without access to labels, dissimilar (negative) points are typically taken to be randomly sampled datapoints, implicitly accepting that these points may, in reality, actually have the same label. Perhaps unsurprisingly, we observe that sampling negative examples from truly different labels improves performance, in a synthetic setting where labels are available. Motivated by this observation, we develop a debiased contrastive objective that corrects for the sampling of same-label datapoints, even without knowledge of the true labels.

Debiased Contrastive Learning NeurIPS 2020 [paper] <br/> Ching-Yao Chuang, Joshua Robinson, Lin Yen-Chen, Antonio Torralba, and Stefanie Jegelka <br/>

Prerequisites

Contrastive Representation Learning

We can train standard (biased) or debiased version (M=1) of SimCLR with main.py on STL10 dataset.

flags:

For instance, run the following command to train a debiased encoder.

python main.py --tau_plus = 0.1

*Due to the implementation of nn.DataParallel(), training with at most 2 GPUs gives the best result.

Linear evaluation

The model is evaluated by training a linear classifier after fixing the learned embedding.

path flags:

python linear.py --model_path results/model_400.pth

Pretrained Models

tau_plusArchLatent DimBatch SizeAccuracy(%)Download
Biasedtau_plus = 0.0ResNet5012825680.15model
Debiasedtau_plus = 0.05ResNet5012825681.85model
Debiasedtau_plus = 0.1ResNet5012825684.26model

Citation

If you find this repo useful for your research, please consider citing the paper

@article{chuang2020debiased,
  title={Debiased contrastive learning},
  author={Chuang, Ching-Yao and Robinson, Joshua and Lin, Yen-Chen and Torralba, Antonio and Jegelka, Stefanie},
  journal={Advances in Neural Information Processing Systems},
  volume={33},
  year={2020}
}

For any questions, please contact Ching-Yao Chuang (cychuang@mit.edu).

Acknowledgements

Part of this code is inspired by leftthomas/SimCLR.