Forked from PICA (https://github.com/Raymond-sci/PICA).
Illustration of our idea. Do contrastive learning from two views: sample and class view. The goal of sample view is to pull positive sample pair together and push negative sample pairs apart. Class view intends to pull positive class pair together and push negative class pairs apart.
The framework of the proposed network: Doubly Contrastive Deep Clustering (DCDC). We have Sample-wise Constrative Loss and Class-wise Constrastive Loss in our DCDC method.Python 2.7 and Pytorch 1.4.0 are required. Please refer to environment.yaml for more details.
- Clone this repo:
git clone https://github.com/ZhiyuanDang/DCDC.git
. - Download datasets: CIFAR-10/100, STL-10 and Tiny-ImageNet.
- Examples of training DCDC on different datasets are provided in
/config
. Use the commandpython main.py --cfgs configs/base.yaml configs/cifar100.yaml
to run the experiments on CIFAR100. Most of the dataset-irrelevant arguments, e.g. optimiser and backbone, are specified inconfigs/base.yaml
. Hence, replaceconfigs/cifar100.yaml
byconfigs/stl10.yaml
to run on STL-10. - Use the flag
--data-root
in command line or modify the config files to set the data path. - The program is run on CPU by default, use the flag
--gpus GPU
to specify the gpu device you would like to use.
Every time the main.py
is run, a new session will be started with the name of current timestamp and all the generated files will be stored in folder sessions/timestamp/
including checkpoints, logs, etc. Use the flag --session
to specify a session name and --debug
to produce no file.
@misc{dang2021doubly,
title={Doubly Contrastive Deep Clustering},
author={Zhiyuan Dang and Cheng Deng and Xu Yang and Heng Huang},
year={2021},
eprint={2103.05484},
archivePrefix={arXiv},
primaryClass={cs.CV}
}