← Open Source
haitongli

knowledge-distillation-pytorch

A PyTorch implementation for exploring deep and shallow knowledge distillation (KD) experiments with flexibility.

Model DevelopmentTraining toolkitsPython
Open on GitHub
Momentum
+0stars in 24 hours0.0%
2.00k
Stars
350
Forks
+0
This week
4
Contributors
Created 2018-03-09 · Updated 2026-10-03 · #9120 today
Top developers
haitongliakarleforjiuzhou

haitongli/knowledge-distillation-pytorch is ranked 9,120 with 1,999 stars.

Same-category comparison

haitongli/knowledge-distillation-pytorch is ranked 9,120 among these 8 peers; JDAI-CV/FaceX-Zoo is ranked 9,117.

Same-category comparison
NameRankMetrics
open-mmlab/mmgeneration9,107
Language:
Python
Stars:
2,009
Forks:
230
Description:
MMGeneration is a powerful toolkit for generative models, based on PyTorch and MMCV.
NVlabs/edm9,112
Language:
Python
Stars:
2,003
Forks:
213
Description:
Elucidating the Design Space of Diffusion-Based Generative Models (EDM).
clementchadebec/benchmark_VAE9,115
Language:
Python
Stars:
2,001
Forks:
178
Description:
Unifying Variational Autoencoder (VAE) implementations in Pytorch (NeurIPS 2022).
JDAI-CV/FaceX-Zoo9,117
Language:
Python
Stars:
2,000
Forks:
431
Description:
A PyTorch Toolbox for Face Recognition.
apple-aiml-research/ml-cvnets9,127
Language:
Python
Stars:
1,995
Forks:
257
Description:
CVNets: A library for training computer vision networks.
logpai/logparser9,129
Language:
Python
Stars:
1,995
Forks:
578
Description:
A machine learning toolkit for log parsing [ICSE'19, DSN'16].
lucidrains/titans-pytorch9,131
Language:
Python
Stars:
1,993
Forks:
210
Description:
Unofficial implementation of Titans, SOTA memory for transformers, in Pytorch.
HobbitLong/PyContrast9,132
Language:
Python
Stars:
1,992
Forks:
180
Description:
PyTorch implementation of Contrastive Learning methods.
Key parameters and specifications
Key parameters and specifications
ParameterValue
LanguagePython
CategoryModel Development
SubcategoryTraining toolkits
Stars1,999
Forks350
Contributors4
Created date2018-03-09
Updated date2026-10-03
Stars in 1 day0
Stars in 7 days0
Rank9,120
Previous rank9,165
Rank change45
7-day stars rank12,185
Previous 7-day stars rank12,248
7-day stars rank change63
Total stars rank6,348
Previous total stars rank6,342
Total stars rank change-6
CountryUSA
README summary

knowledge-distillation-pytorch Exploring knowledge distillation of DNNs for efficient hardware solutions Author: Haitong Li Framework: PyTorch Dataset: CIFAR-10 Features A framework for exploring "shallow" and "deep" knowledge distillation (KD) experiments Hyperparameters defined by "params. json" universally (avoiding long argparser commands) Hyperparameter searching and result synthesizing (as a table) Progress bar, tensorboard support, and checkpoint saving/loading (utils. py) Pretrained teacher models available for download Install Clone the repo Install the dependencies (including Pytorch) Organizatoin: . py: main entrance for

train/eval with or without KD on CIFAR-10 . /experiments/: json files for each experiment; dir for hypersearch . /model/: teacher and student DNNs, knowledge distillation (KD) loss defination, dataloader Key notes about usage for your experiments: Download the zip file for pretrained teacher model checkpoints from "experiments. zip" Simply move the unzipped subfolders into 'knowledge-distillation-pytorch/experiments/' (replacing the existing ones if necessary; follow the default path naming) Call train. py to start training 5-layer CNN with ResNet

-18's dark knowledge, or training ResNet-18 with state-of-the-art deeper models distilled Use search_hyperparams. py for hypersearch Hyperparameters are defined in params. Refer to the header of search_hyperparams. py for details Train (dataset: CIFAR-10) Note: all the hyperparameters can be found and modified in 'params. Li, "Exploring knowledge distillation of Deep neural nets for efficient hardware solutions," CS230 Report, 2018 Hinton, Geoffrey, Oriol Vinyals, and Jeff Dean. "Distilling the knowledge in a neural network

.

Frequently asked questions

How many stars and forks are recorded?

haitongli/knowledge-distillation-pytorch has 1,999 stars and 350 forks.

What is the repository rank?

haitongli/knowledge-distillation-pytorch is ranked 9,120.

What language and category are recorded?

haitongli/knowledge-distillation-pytorch has 1,999 stars, uses Python and belongs to Model Development.

Which repository is closest in rank?

haitongli/knowledge-distillation-pytorch is compared with JDAI-CV/FaceX-Zoo, ranked 9,117 with 2,000 stars.

README

knowledge-distillation-pytorch

  • Exploring knowledge distillation of DNNs for efficient hardware solutions
  • Author: Haitong Li
  • Framework: PyTorch
  • Dataset: CIFAR-10

Features

  • A framework for exploring "shallow" and "deep" knowledge distillation (KD) experiments
  • Hyperparameters defined by "params.json" universally (avoiding long argparser commands)
  • Hyperparameter searching and result synthesizing (as a table)
  • Progress bar, tensorboard support, and checkpoint saving/loading (utils.py)
  • Pretrained teacher models available for download

Install

  • Clone the repo

    git clone https://github.com/peterliht/knowledge-distillation-pytorch.git
    
  • Install the dependencies (including Pytorch)

    pip install -r requirements.txt
    

Organizatoin:

  • ./train.py: main entrance for train/eval with or without KD on CIFAR-10
  • ./experiments/: json files for each experiment; dir for hypersearch
  • ./model/: teacher and student DNNs, knowledge distillation (KD) loss defination, dataloader

Key notes about usage for your experiments:

  • Download the zip file for pretrained teacher model checkpoints from "experiments.zip"
  • Simply move the unzipped subfolders into 'knowledge-distillation-pytorch/experiments/' (replacing the existing ones if necessary; follow the default path naming)
  • Call train.py to start training 5-layer CNN with ResNet-18's dark knowledge, or training ResNet-18 with state-of-the-art deeper models distilled
  • Use search_hyperparams.py for hypersearch
  • Hyperparameters are defined in params.json files universally. Refer to the header of search_hyperparams.py for details

Train (dataset: CIFAR-10)

Note: all the hyperparameters can be found and modified in 'params.json' under 'model_dir'

-- Train a 5-layer CNN with knowledge distilled from a pre-trained ResNet-18 model

python train.py --model_dir experiments/cnn_distill

-- Train a ResNet-18 model with knowledge distilled from a pre-trained ResNext-29 teacher

python train.py --model_dir experiments/resnet18_distill/resnext_teacher

-- Hyperparameter search for a specified experiment ('parent_dir/params.json')

python search_hyperparams.py --parent_dir experiments/cnn_distill_alpha_temp

--Synthesize results of the recent hypersearch experiments

python synthesize_results.py --parent_dir experiments/cnn_distill_alpha_temp

Results: "Shallow" and "Deep" Distillation

Quick takeaways (more details to be added):

  • Knowledge distillation provides regularization for both shallow DNNs and state-of-the-art DNNs
  • Having unlabeled or partial dataset can benefit from dark knowledge of teacher models

-Knowledge distillation from ResNet-18 to 5-layer CNN

Model Dropout = 0.5 No Dropout
5-layer CNN 83.51% 84.74%
5-layer CNN w/ ResNet18 84.49% 85.69%

-Knowledge distillation from deeper models to ResNet-18

Model Test Accuracy
Baseline ResNet-18 94.175%
+ KD WideResNet-28-10 94.333%
+ KD PreResNet-110 94.531%
+ KD DenseNet-100 94.729%
+ KD ResNext-29-8 94.788%

References

H. Li, "Exploring knowledge distillation of Deep neural nets for efficient hardware solutions," CS230 Report, 2018

Hinton, Geoffrey, Oriol Vinyals, and Jeff Dean. "Distilling the knowledge in a neural network." arXiv preprint arXiv:1503.02531 (2015).

Romero, A., Ballas, N., Kahou, S. E., Chassang, A., Gatta, C., & Bengio, Y. (2014). Fitnets: Hints for thin deep nets. arXiv preprint arXiv:1412.6550.

https://github.com/cs230-stanford/cs230-stanford.github.io

https://github.com/bearpaw/pytorch-classification

Nearby in the ranking
Similar items