Giter VIP home page Giter VIP logo

aps's Introduction

Asymmetric Patch Sampling for Contrastive Learning

PyTorch implementation and pre-trained models for paper APS: Asymmetric Patch Sampling for Contrastive Learning.

APS is a novel asymmetric patch sampling strategy for contrastive learning, to further boost the appearance asymmetry for better representations. APS significantly outperforms the existing self-supervised methods on both ImageNet-1K and CIFAR dataset, e.g., 2.5% finetune accuracy improvement on CIFAR100. Additionally, compared to other self-supervised methods, APS is more efficient on both memory and computation during training.

Requirements


conda create -n asp python=3.9
pip install -r requirements.txt

Datasets


Torchvision provides CIFAR10, CIFAR100 datasets. The root paths of data are respectively set to ./dataset/cifar10 and ./dataset/cifar100. ImageNet-1K dataset is placed at ./dataset/ILSVRC.

Pre-training


To start the APS pre-training, simply run the following commands.

• Arguments

  • arch is the architecture of the pre-trained models,you can choose vit-tiny, vit-small and vit-base.
  • dataset is the pre-trained dataset.
  • data-root is the path of the dataset.
  • nepoch is the pre-trained epochs.

Run APS with ViT-Small/2 network on a single node on CIFAR100 for 1600 epochs with the following command.

python main_pretrain.py --arch='vit-small' --dataset='cifar100' --data-root='./dataset/cifar100' --nepoch=1600

Finetuning


To finetune ViT-Small/2 on CIFAR100 with the following command.

python main_finetune.py --arch='vit-small' --dataset='cifar100' --data-root='./dataset/cifar100'  \
                   --pretrained-weights='./weight/pretrain/cifar100/small_1600ep_5e-4_100.pth'

Trained Model Weights & Finetune Accuracy


  • CIFAR10 and CIFAR100
Dataset Training (#Epochs) ViT-Tiny/2 ViT-Small/2 ViT-Base/2
CIFAR10 Pretrain (1600) download download download
Finetune (100) download download download
Accuracy 97.2% 98.1% 98.2%
Pretrain (3200) download download download
Finetune (100) download download download
Accuracy 97.5% 98.2% 98.3%
CIFAR100 Pretrain (1600) download download download
Finetune (100) download download download
Accuracy 83.4% 84.9% 85.9%
Pretrain (3200) download download download
Finetune (100) download download download
Accuracy 83.4% 85.3% 86.0%
  • ImageNet-1K
Backbone Pretrain (300 epochs) Finetune (100 epochs)
ViT-S/16 download 82.1% (download)
ViT-B/16 download 84.2% (download)

LICENSE


This project is under the CC-BY-NC 4.0 license. See LICENSE for details.

aps's People

Contributors

sccbhxc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.