Coder Social home page Coder Social logo

bruinxiong / zeroshotknowledgetransfer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from polo5/zeroshotknowledgetransfer

0.0 2.0 0.0 5.98 MB

Accompanying code for the paper "Zero-shot Knowledge Transfer via Adversarial Belief Matching"

Python 21.62% Shell 3.74% Jupyter Notebook 74.64%

zeroshotknowledgetransfer's Introduction

Zero Shot Knowledge Transfer

This is accompanying code for the NeurIPS 2019 spotlight paper "Zero-shot Knowledge Transfer via Adversarial Belief Matching" see arxiv

What is this work about? (TLDR)

picture

Our task is to compress a large neural network (teacher) into a smaller one (student), but we assume that the data used to train the teacher is not available anymore. We thus generate pseudo points adversarially (yellow markers above) and use those to match the student (right) to the teacher (left).

Environment

  • Python 3.6
  • pytorch 1.0.0 (both cpu and gpu version tested)
  • tensorboard 1.7.0 (for logging, + needs tensorflow)

Run zero shot knowledge transfer

  1. Pretrain a teacher for the dataset/architecture you want (or download some of mine here)
  2. Make sure you have the same folder structure as in the link above, i.e. Pretrained/{dataset}/{architecture}/last.pth.tar
  3. Edit the paths in e.g. scripts/ZeroShot/main0.sh and run it

Make transition curves

  1. Pretrain a zero-shot student or a student distilled with KD+AT (or download some of mine here)
  2. Edit the paths in e.g. scripts/TransitionCurves/transition_curves0.sh and run it
  3. This saves .pickle file with all the transition curves
  4. You can import that file in notebooks/transition_curves_and_error.ipynb to plot the transition curves and calculate MTE scores

Cite

If you use this work please consider citing:

@article{Micaelli2019ZeroShotKT,
  author    = {Paul Micaelli and
               Amos J. Storkey},
  title     = {Zero-shot Knowledge Transfer via Adversarial Belief Matching},
  journal   = {CoRR},
  volume    = {abs/1905.09768},
  year      = {2019},
  url       = {http://arxiv.org/abs/1905.09768},
  archivePrefix = {arXiv},
  eprint    = {1905.09768},
  timestamp = {Wed, 29 May 2019 11:27:50 +0200},
  biburl    = {https://dblp.org/rec/bib/journals/corr/abs-1905-09768},
  bibsource = {dblp computer science bibliography, https://dblp.org}
}

Baselines

A few people have asked for the KD+AT few shot baselines so I've made them available in this repo

Notes

  • Version 1 and 2 on arxiv have lower accuracy scores because I hadn't trained batchnorm layers properly.
  • Attention only gives you an average of 2% boost across all architectures tested so you can delete that code if you want to save on memory/compute time.

zeroshotknowledgetransfer's People

Contributors

polo5 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.