Git Product home page Git Product logo

metacontrastive's Introduction

The Close Relationship Between Contrastive Learning and Meta-Learning

Abstract

Contrastive learning has recently taken off as a paradigm for learning from unlabeled data. In this paper, we discuss the close relationship between contrastive learning and meta-learning under a certain task distribution. We complement this observation by showing that established meta-learning methods, such as Prototypical Networks, achieve comparable performance to SimCLR when paired with this task distribution. This relationship can be leveraged by taking established techniques from meta-learning, such as task-based data augmentation, and showing that they benefit contrastive learning as well. These tricks also benefit state-of-the-art self-supervised learners without using negative pairs such as BYOL, which achieves 94.6% accuracy on CIFAR-10 using a self-supervised ResNet-18 feature extractor trained with our meta-learning tricks. We conclude that existing advances designed for contrastive learning or meta-learning can be exploited to benefit the other, and it is better for contrastive learning researchers to take lessons from the meta-learning literature (and vice-versa) than to reinvent the wheel.

SSL training Examples

  1. To train with SimCLR for 100 epochs on ImageNet with batch size 256:

    python train.py --config configs/imagenet_train_epochs100_bs512.yaml --dist_address '127.0.0.1:1672' --n_supp 1 --n_query 1 --multiplier 2 --arch ResNet50 --seed 1234 --run_id 000001 --head contrastive --accu_iter 1 --batch_size 256 --lr 2.4 --iters 1000800 --eval_freq 100080 --save_freq 12510 --temperature 10.
  2. To train with SimCLR with R2D2 head for 100 epochs on ImageNet with batch size 256:

    python train.py --config configs/imagenet_train_epochs100_bs512.yaml --dist_address '127.0.0.1:1672' --n_supp 1 --n_query 1 --multiplier 2 --arch ResNet50 --seed 1234 --run_id 000001 --head R2D2 --accu_iter 1 --batch_size 256 --lr 2.4 --iters 1000800 --eval_freq 100080 --save_freq 12510 --temperature 0.1

Evaluation Examples

  1. To test models for linear evaluation:
python train.py --config configs/imagenet_eval.yaml --encoder_ckpt logs/exman-configs/imagenet_train_epochs100_bs512.yaml/runs/000001/checkpoint-1000800.pth.tar --run_id 000001
  1. To test models for semi-supervised learning with 1% labeled data:
python train.py --config configs/imagenet_semi_eval.yaml --train_size 1 --encoder_ckpt logs/exman-configs/imagenet_train_epochs100_bs512.yaml/runs/000005/checkpoint-1000800.pth.tar --eval_freq 100 --log_freq 100 --run_id 000001 --iters 3000 --lr 0.05
  1. To test models for semi-supervised learning with 10% labeled data:
python train.py --config configs/imagenet_semi_eval.yaml --encoder_ckpt logs/exman-configs/imagenet_train_epochs100_bs512.yaml/runs/000001/checkpoint-1000800.pth.tar --eval_freq 100 --log_freq 100 --run_id 000001 --iters 60000 --train_size 10 --lr 0.1

Acknowledgments

This code is based on the implementations of [SimCLR]https://github.com/AndrewAtanov/simclr-pytorch, MetaOptNet and MetaAug.

metacontrastive's People

Contributors

renkunni avatar

Stargazers

 avatar Sadia Afrin Purba avatar  avatar JacobXu avatar  avatar 又几番迷离 avatar  avatar  avatar Edoardo Piccari avatar Avi Schwarzschild avatar  avatar Arpit Bansal avatar Anshuman Suri avatar Jonas Geiping  avatar  avatar Olivia-fsm avatar Huanhuaner avatar dqliu avatar fikry102 avatar

Watchers

 avatar

Forkers

helpfirecode

metacontrastive'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.