Giter VIP home page Giter VIP logo

crossarch_kd's Introduction

Cross-Architecture Knowledge Distillation

This is an open source implementation of the paper called "Cross-Architecture Knowledge Distillation".

Yufan Liu, Jiajiong Cao, Bing Li, Weiming Hu, Jingting Ding, Liang Li. Cross-Architecture Knowledge Distillation. Asian Conference on Computer Vision (ACCV): Long Beach, China. 2022.12.04-2022.12.08.

Abstract

Transformer attracts much attention because of its ability to learn global relations and superior performance. In order to achieve higher performance, it is natural to distill complementary knowledge from Transformer to convolutional neural network (CNN). However, most existing knowledge distillation methods only consider homologous-architecture distillation, such as distilling knowledge from CNN to CNN. They may not be suitable when applying to cross-architecture scenarios, such as from Transformer to CNN. To deal with this problem, a novel cross-architecture knowledge distillation method is proposed. Specifically, instead of directly mimicking output/intermediate features of the teacher, partially cross attention projector and group-wise linear projector are introduced to align the student features with the teacher's in two projected feature spaces. And a multi-view robust training scheme is further presented to improve the robustness and stability of the framework. Extensive experiments show that the proposed method outperforms 14 state-of-the-arts on both smallscale and large-scale datasets.

Citation

If you find our method useful in your research, please cite our paper:

@InProceedings{Liu_2022_ACCV,
    author    = {Liu, Yufan and Cao, Jiajiong and Li, Bing and Hu, Weiming and Ding, Jingting and Li, Liang},
    title     = {Cross-Architecture Knowledge Distillation},
    booktitle = {Proceedings of the Asian Conference on Computer Vision (ACCV)},
    month     = {December},
    year      = {2022},
    pages     = {3396-3411}
}

Framework

Framework

Requirements

  • The codes are tested on torch==1.12.0 on cuda==11.3 with 8 V100 (A100) cards.
  • torch >= 1.12.0
  • cuda >= 11.3

Usage

  • step 1: obtain your TORCHVISION_MODEL_PATH and TORCH_NN_PATH
import os
import torchvision
os.systm('export TORCHVISION_MODEL_PATH={:s}'.format(torchvision.models.__path__[0]))
import torch
os.systm('export TORCH_NN_PATH={:s}'.format(torch.nn.__path__[0]))
  • step2: make modifications to the native torch to extract necessary mid-level outputs for CAKD
cd CAKD
cp cakd_modified_files/resnet.py ${TORCHVISION_MODEL_PATH}/resnet.py
cp cakd_modified_files/vision_transformer.py ${TORCHVISION_MODEL_PATH}/vision_transformer.py
cp cakd_modified_files/functional.py ${TORCH_NN_PATH}/functional.py
  • step3: run experiments
#run student baseline
sh experiments/run_baseline.sh
#run logits KD
sh experiments/run_logits.sh

We adopt native pytorch augmentors to augment the data for adversarial training mentioned in the paper.

#run logits CAKD
sh experiments/run_cakd.sh

Notice and Performance

The performance reported in the original paper is produced based on a customized torch (with many customized data augmentation techniques). At this end, the performance of the student, teacher, and distilled student is relatively higher than the public models. Unfortunately, because of privacy and security concerns, we are not able to provide the full version of this torch. Instead, we make the key codes of CAKD public in this repo.

Since some customized operations and teacher model are not available, the performance of the student, teacher, and distilled student is lower than that reported in the paper. However, the performance gain compared with competing methods is significant. The performance is provided below, researchers could consider to compare the performance gain.

Performance on ImageNet:

Method Top-1 Top-5
Baseline (ResNet50) 73.82% 91.97%
Logits 74.48% 92.29%
CAKD (Ours) 76.21% 93.09%

Contact

If any question, please contact [email protected] or use public issues section of this repository.

crossarch_kd's People

Contributors

yufanliu avatar

Stargazers

 avatar  avatar  avatar 姚亮亮 avatar  avatar Sunki avatar WZY_^ avatar  avatar  avatar  avatar  avatar Zhiyu Zhao avatar

Watchers

 avatar

Forkers

sunkilin

crossarch_kd's Issues

Transform.py file issue

Hey, it gives me error of not having the ImageClassification funtion in transform.py. Are there any missing files in the code?
image

TPAMI code will be released ?

Y. Liu, J. Cao, B. Li, W. Hu and S. Maybank, "Learning to Explore Distillability and Sparsability: A Joint Framework for Model Compression," in IEEE Transactions on Pattern Analysis and Machine Intelligence, vol. 45, no. 3, pp. 3378-3395, 1 March 2023, doi: 10.1109/TPAMI.2022.3185317.

Could you release the code with this paper? I want to use it and if I have any related paper will be pubulished,I will cite your paper. thanks!

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.