You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 31, 2023. It is now read-only.
This is a PyTorch implementation of the SimSiam paper:
@Article{chen2020simsiam,
author = {Xinlei Chen and Kaiming He},
title = {Exploring Simple Siamese Representation Learning},
journal = {arXiv preprint arXiv:2011.10566},
year = {2020},
}
Preparation
Install PyTorch and download the ImageNet dataset following the official PyTorch ImageNet training code. Similar to MoCo, the code release contains minimal modifications for both unsupervised pre-training and linear classification to that code.
In addition, install apex for the LARS implementation needed for linear classification.
Unsupervised Pre-Training
Only multi-gpu, DistributedDataParallel training is supported; single-gpu or DataParallel training is not supported.
To do unsupervised pre-training of a ResNet-50 model on ImageNet in an 8-gpu machine, run:
python main_simsiam.py \
-a resnet50 \
--dist-url 'tcp://localhost:10001' --multiprocessing-distributed --world-size 1 --rank 0 \
--fix-pred-lr \
[your imagenet-folder with train and val folders]
The script uses all the default hyper-parameters as described in the paper, and uses the default augmentation recipe from MoCo v2.
The above command performs pre-training with a non-decaying predictor learning rate for 100 epochs, corresponding to the last row of Table 1 in the paper.
Linear Classification
With a pre-trained model, to train a supervised linear classifier on frozen features/weights in an 8-gpu machine, run:
python main_lincls.py \
-a resnet50 \
--dist-url 'tcp://localhost:10001' --multiprocessing-distributed --world-size 1 --rank 0 \
--pretrained [your checkpoint path]/checkpoint_0099.pth.tar \
--lars \
[your imagenet-folder with train and val folders]
The above command uses LARS optimizer and a default batch size of 4096.