GithubHelp home page GithubHelp logo

tsungweitsai / simclr Goto Github PK

View Code? Open in Web Editor NEW
9.0 2.0 1.0 32 KB

Unofficial Pytorch Implementation of "A Simple Framework for Contrastive Learning of Visual Representations"

Python 100.00%
simclr representation-learning pytorch

simclr's Introduction

SimCLR

Unofficial Pytorch Implementation of "A Simple Framework for Contrastive Learning of Visual Representations (Paper)"

Train on CIFAR

Currently, we support training with LARS, amp or neither of them. The commands are as follows:

  • LARS
CUDA_VISIBLE_DEVICES=0,1 python train_simclr.py \
 --LARS --nce_t 0.5 --epoch 1000 --learning_rate 1.0 --lr_warmup 10 --batch_size 256  --num_workers 8 --filter_weight_decay bn,bias \  
 --contrastive_model simclr --aug simple --weight_decay 1e-6 --model resnet50_cifar --dataset cifar \
 --model_path ./model_save --tb_path ./tensorboard --data_folder ./  
  • amp
CUDA_VISIBLE_DEVICES=0,1 python train_simclr.py \
 --amp --nce_t 0.5 --epoch 1000 --learning_rate 1.0 --lr_warmup 10 --batch_size 256  --num_workers 8 --filter_weight_decay bn,bias \
 --contrastive_model simclr --aug simple --weight_decay 1e-6 --model resnet50_cifar --dataset cifar \
 --model_path ./model_save --tb_path ./tensorboard --data_folder ./  
  • Normal training
CUDA_VISIBLE_DEVICES=0,1 python train_simclr.py \
 --nce_t 0.5 --epoch 1000 --learning_rate 1.0 --lr_warmup 10 --batch_size 256  --num_workers 8 --filter_weight_decay bn,bias \
 --contrastive_model simclr --aug simple --weight_decay 1e-6 --model resnet50_cifar --dataset cifar \
 --model_path ./model_save --tb_path ./tensorboard --data_folder ./  

Installation

  • python 3.6+
  • PyTorch 1.0+
  • CUDA 10.0
  • torchlars
  • tensorboard_logger
  • scikit-image
  • apex (for amp)

Notice

The implementation may be slightly different from the official implementation. For instance, we use the shuffle BN(Paper) instead of the Global BN trick. In addition, the code is currently tested on CIFAR-10 only. We can attain around 90% accuracy after training 1000 epochs.

If you should find any mistakes in the code or better hyper-parameter settings that achieves higher accuracy, please kindly let us know or submit the pull request. Thank you.

Acknowledgements

The implementation heavily relies on the following repos:

  1. CMC: Contrastive Multiview Coding (Paper, Code)
  2. InsDis: Unsupervised Feature Learning via Non-Parametric Instance-level Discrimination (Paper, Code)
  3. Unsupervised Embedding Learning via Invariant and Spreading Instance Feature (Paper, Code)
  4. SimCLR (official tensorflow implementation, Code)

simclr's People

Contributors

tsungweitsai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

mohammadjavadd

simclr's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.