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 수를 맞춘다.

$$ L_{Hint}(V, Z) = ||V-Z||_{2}^{2} $$ - Detection head

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

$$ L_{b}(R_{s}, R_{t}, y) = - \begin{cases} ||R_{s}-y||{2}^{2}, & if \, ||R-y||{2}^{2} + m > || R_t - y || $$}^{2} \ 0, & \mathrm{otherwise} \end{cases

이때 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는 다음과 같다.

$$ \mathcal{L} = \mathcal{L}{cGAN}(x) + \lambda} \mathcal{L{recon} + \lambda(x) $$} \mathcal{L}_{distill

$$ \mathcal{L}_{recon} = \begin{cases} {||G(x) - y||} & \mathrm{paired} \ \mathrm{cGANs} \ {||G(x) - G'(x)||} & \mathrm{unpaired} \ \mathrm{cGANs} \end{cases} $$

$$ \mathcal{L}{distill} = \sum^n ||G_k(x) - f_k(G_k'(x))|| $$ $$

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


10.8 KD for NLP

MobileBERT: a Compact Task-Agnostic BERT for Resource-Limited Devices 논문(2020)

MobileBERT 논문에서는 NLP 도메인에서, 교사의 feature map과 attention 정보를 쩐달하는 방식으로 KD를 구현했다.

MobileBERT


10.9 Network Augmentation

NETWORK AUGMENTATION FOR TINY DEEP LEARNING 논문(2022)

large model에서 overfitting을 피하기 위해 사용하는 data augmentation, dropout과 같은 방법은, tiny model에서 오히려 악영향을 미친다.

cutout, mixup, rotation, flip 등

data augmentation

dropout

다음은 tiny model에서 해당 기법을 적용했을 때, 성능 차이를 나타내는 그림이다.

AutoAugment, dropout


10.9.1 Training Process

NetAug는 모델 자체를 증강하는 방식을 택한다.(reverse dropout)

반대로 large model에서는 overfitting을 유발하므로 주의해야 한다.

각 레이어의 #channels을 늘려, dynamic neural network를 학습한다. (weight sharing)

original, augmented model의 forward, backward를 함께 수행한다.

NetAug step 1

좌: original tiny model, 우: augmented model

이때 loss function은 base supervision, auxiliary supervision 두 항의 결합으로 표현된다.

$$ {\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