Code Monkey home page Code Monkey logo

explaining-knowledge-distillation-by-quantifying-the-knowledge's Introduction

Explaining Knowledge Distillation by Quantifying the Knowledge

Here is the code for our paper: Explaining Knowledge Distillation by Quantifying the Knowledge (CVPR 2020).

Xu Cheng, Zhefan Rao, Yilan Chen, Quanshi Zhang

Requirements

  • python
  • pytorch
  • torchvision

How to Use

You can specify different hyperparameters through command line.

  1. /train_net/train_net.py

    • Train the teacher network or the baseline network
    • Run python /train_net/train_net.py
  2. /distillation/distillation.py

    • Use knowledge distillation to train the student network
    • Run python /distillation/distillation.py --teacher_checkpoint YOUR_CHECKPOINT_DIR
  3. /sigma/train_sigma.py

    • Compute the information discarding
    • Run python /sigma/train_sigma.py --checkpoint_root YOUR_CHECKPOINT_DIR
  4. /sigma/find_knowledge_new.py

    • Compute the three type of metrices in the paper

    • Run python /sigma/find_knowledge_new.py

    • You need to change the following paths to your own trained result paths, e.g.

      model_name = 'vgg16'
      layer = 'conv'
      date = '0415'
      label_sigma_root = './KD/sigma_result/ILSVRC_vgg16_label_net_conv_0415/'
      distil_sigma_root = './KD/sigma_result/ILSVRC_vgg16_distil_net_conv_0415/'
      label_checkpoint_path = './KD/trained_model/ILSVRC_vgg16_without_pretrain_1018/'
      distil_checkpoint_path = './KD/trained_model/ILSVRC_vgg16_distil_conv_0415/'
      
  5. /models/model.py

    • Use PyTorch to implement models, including the NoiseLayer used to compute sigma
  6. /function/dataset.py

    • PyTorch dataset implementation
  7. /function/logger.py

    • Logger class, which is used to record the intermediate result during training, such as loss and accuracy
  8. /supplement/train_net_supplement.py

    • To train a teacher from scratch
    • Run python /supplement/train_net_supplement.py

Citation

Please cite the following paper, if you use this code.

@inproceedings{9157818,
  author={Cheng, Xu and Rao, Zhefan and Chen, Yilan and Zhang, Quanshi},
  booktitle={2020 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)}, 
  title={Explaining Knowledge Distillation by Quantifying the Knowledge}, 
  year={2020},
  pages={12922-12932},
  keywords={},
  doi={10.1109/CVPR42600.2020.01294},
  ISSN={2575-7075},
  month={June}
}

explaining-knowledge-distillation-by-quantifying-the-knowledge's People

Contributors

cx1208 avatar jenniferlyx 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.