Branch Log · Open in interactive viewer →

10 Knowledge Distillation

Lecture 10 - Knowledge Distillation | MIT 6.S965

EfficientML.ai Lecture 9 - Knowledge Distillation (MIT 6.5940, Fall 2023, Zoom)


10.5 KD for Object Detection

Object Detection 도메인에서는, 크게 두 가지 문제를 추가로 해결해야 한다.

이때, bounding box는 classification이 아니라, regression 문제에 해당된다.


10.5.1 Distillation Pipeline for Object Detection

Learning Efficient Object Detection Models with Knowledge Distillation 논문(2017)

Object Detection의 특징에 맞춰, 위 논문에서는 다음과 같은 절차를 통해 KD를 수행한다.

feature imitation

교사와 학생의 intermediate feature map을 비교한다.

1x1 conv로 channel 수를 맞춘다.

LHint(V,Z)=||V−Z||22

classification, regression 결과를 모두 도출한 뒤 loss를 계산한다.

Lb(Rs,Rt,y)=−{||Rs−y||22,if||Rs−y||22+m>||Rt−y||220,otherwise

이때 margin을 두어, 학생 성능이 교사 성능 + margin m 을 넘어서는 순간, loss가 0이 되며 학습이 중단되도록 구현했다.


10.5.2 Convert Regression to Classification Problem

Localization Distillation for Dense Object Detection 논문(2022)

혹은 regression 문제인 bounding box을, classification 문제로 바꿔서 KD를 수행할 수 있다.

bounding box


10.6 KD for Semantic Segmentation

Structured Knowledge Distillation for Semantic Segmentation 논문(2019)

Semantic Segmentation 도메인에서는 Discriminator을 사용한 KD 방법이 제안되었다. (Adversarial Distillation)

structured KD

adversarial loss: 학생이 discriminator를 속일 수 있도록 학습된다.


10.7 KD for GAN

GAN Compression: Efficient Architectures for Interactive Conditional GANs 논문(2020)

KD for GAN

training objective는 다음과 같다.

ℒ=ℒcGAN(x)+λreconℒrecon+λdistillℒdistill(x) ℒrecon={||G(x)−y||paired cGANs||G(x)−G′(x)||unpaired cGANs ℒdistill=∑k=1n||Gk(x)−fk(Gk′(x))|| −cGANLoss

\mathcal{L}{cGAN} = \mathbb{E}_x[\log (1- D(x, G(x)))]}[\log D(x,y)] + \mathbb{E

−−−##10.8KDforNLP>[MobileBERT:aCompactTask−AgnosticBERTforResource−LimitedDevices논문(2020)](https://arxiv.org/abs/2004.02984)MobileBERT논문에서는NLP도메인에서,교사의featuremap과attention정보를쩐달하는방식으로KD를구현했다.![MobileBERT](https://raw.githubusercontent.com/erectbranch/MIT−Efficient−AI/master/2022/lec10/summary02/images/NLPKD.png)−FeatureMapTransfer(FMT)−AttentionTransfer(AT)−−−##10.9NetworkAugmentation>[NETWORKAUGMENTATIONFORTINYDEEPLEARNING논문(2022)](https://arxiv.org/pdf/2110.08890.pdf)largemodel에서overfitting을피하기위해사용하는**dataaugmentation**,**dropout**과같은방법은,tinymodel에서오히려악영향을미친다.−dataaugmentationcutout,mixup,rotation,flip등![dataaugmentation](https://raw.githubusercontent.com/erectbranch/MIT−Efficient−AI/master/2022/lec10/summary02/images/dataaugmentation.png)−dropout![dropout](https://raw.githubusercontent.com/erectbranch/MIT−Efficient−AI/master/2022/lec10/summary02/images/dropout.png)다음은tinymodel에서해당기법을적용했을때,성능차이를나타내는그림이다.![AutoAugment,dropout](https://raw.githubusercontent.com/erectbranch/MIT−Efficient−AI/master/2022/lec10/summary02/images/dataaugmentdropoutcompare.png)−−−###10.9.1TrainingProcess**NetAug**는모델자체를증강하는방식을택한다.(reversedropout)>반대로largemodel에서는overfitting을유발하므로주의해야한다.−augmentmodel각레이어의#channels을늘려,dynamicneuralnetwork를학습한다.(**weightsharing**)−Step1original,augmentedmodel의forward,backward를함께수행한다.![NetAugstep1](https://github.com/erectbranch/MIT−Efficient−AI/blob/master/2022/lec10/summary02/images/NetAugstep1.png)>좌:originaltinymodel,우:augmentedmodel이때lossfunction은basesupervision,auxiliarysupervision두항의결합으로표현된다.

{\mathcal{L} }{aug} = {\mathcal{L} }(W]) $$}) + {\alpha}{\mathcal{L} }([W_{base}, W_{aug


10.9.2 NetAug Learning Curve

다음은 ImageNet 데이터셋을 이용한 학습에서 NetAug를 적용했을 때의 성능을 나타낸 그림이다.

Learning curves on ImageNet