Git Product home page Git Product logo

isotonicdataaugmentation's Introduction

CODE for Isotonic Data Augmentation For Knowledge Distillation

Here is the code for the paper Isotonic Data Augmentation For Knowledge Distillation

Train Teacher Model

To pre-train a teacher-net for the downsteam Knowledge Distillation, run:

python train_teacher.py --dataset <dataset> --arch <teacher_model_architecture> --batch-size <batch_size> --weight-decay <weigth_decay>

For example, to train a ResNet50 teacher model, run:

python train_teacher.py --dataset CIFAR100 --arch resnet50 --batch-size 128 --weight-decay 5e-4

Knowledge Distillation Through Conventional Method

The conventional method for knowledge distillation is using the soft label from teacher-net and ground truth to train student-net.

python kd_main.py --dataset <dataset> --teacher_arch <teacher_arch> --arch <studentj_arch> --batch_size <batch_size> --weight_decay <weight_decay> --temperature <temperature> --alpha <alpha> --lr <learning_rate>

For example, to distill ResNet18 from ResNet50, run:

python kd_main.py --dataset CIFAR100 --teacher-arch resnet50 --arch resnet18 --batch_size 128 --weight_decay 0.0005 --temperature 4.5 --alpha 0.95 --lr 0.1

Isotonic Data Augmentation for Knowledge Distillation

To distill student-net by calibrating the soft labels when applied a data augmentation method, run:

python kd_main.py --dataset <dataset> --num_classes <dataset_num_classes> --batch_size <batch_size> --epochs 200 --teacher_arch <teacher_arch> --arch <student_arch> --lr <lr> --weight_decay <weight_decay> --mixup_method <mixup_method> --temperature <temperature> --alpha <alpha> --calibration_method <calibration_method>  --soft_constraint_ratio <soft_constraint_ratio>

Examples

  • (KD Mixup) KD-i, distill ResNet18 from ResNet50, run:
python kd_main.py --dataset CIFAR100 --num_classes 100 --batch_size 128 --epochs 200 --teacher_arch resnet50 --arch resnet18 --lr 0.1 --weight_decay 5e-4 --mixup_method mixup --temperature 4.5 --alpha 0.95 --calibration_method isotonic  --soft_constraint_ratio 2
  • (KD Mixup) KD-p, distill ResNet18 from ResNet50, run:
python kd_main.py --dataset CIFAR100 --num_classes 100 --batch_size 128 --epochs 200 --teacher_arch resnet50 --arch resnet18 --lr 0.1 --weight_decay 5e-4 --mixup_method mixup --temperature 4.5 --alpha 0.95 --calibration_method isotonic_appr  --soft_constraint_ratio 2
  • (KD CutMix) KD-i, distill ResNet18 from ResNet50, run:
python kd_main.py --dataset CIFAR100 --num_classes 100 --batch_size 128 --epochs 200 --teacher_arch resnet50 --arch resnet18 --lr 0.1 --weight_decay 5e-4 --mixup_method cutmix --temperature 4.5 --alpha 0.95 --calibration_method isotonic --soft_constraint_ratio 2
  • (KD CutMix) KD-p, distill ResNet18 from ResNet50, run:
python kd_main.py --dataset CIFAR100 --num_classes 100 --batch_size 128 --epochs 200 --teacher_arch resnet50 --arch resnet18 --lr 0.1 --weight_decay 5e-4 --mixup_method cutmix --temperature 4.5 --alpha 0.95 --calibration_method isotonic_appr  --soft_constraint_ratio 2

NOTE: As for CRD experiments, replace kd_main.py with crd_kd.py in the above commands.

isotonicdataaugmentation's People

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.