논문 읽기/Classification

[논문 읽기] (2021) Knowledge distillation: A good teacher is patient and consistent

AI 꿈나무 2021. 6. 22. 01:14
반응형

 안녕하세요, 오늘 읽은 논문은 Knowledge distillation: A good teacher is patient and consitent 입니다.

 

 논문을 직역해보자면 '지식 증류: 좋은 선생님은 참을성이 있고 일관성이 있다.' 입니다. 논문에서 하고 싶은 말이 논문 제목에 다 담겨져 있습니다. 참을성 = 오랜 시간 학습, 일관성 = teacher와 student 동일한 augmentation 적용하기 입니다.

 

 해당 논문은 model compression을 목적으로 knowledge distillation을 사용합니다. knowledge distillation을 function matching으로 보는데, 해당 논문이 제안하는 function matching 방법으로 knowledge distillation을 적용하면 student가 teacher의 accuracy에 도달합니다. teacher와 student의 정확도는 동일한데, student의 model size는 작으므로 이는 model compression 방법으로 생각해 볼 수 있습니다.

 

 이 논문은 기존의 Knowledge distillation loss를 동일하게 사용하고, teacher model은 BiT-M-R152x2(152 layers, width x2), student model은 BiT-ResNet-50을 사용합니다.

 

 왜 knowledge distillation을 model compression에 사용할까요? 그 이유는 최신 모델들이 높은 정확도를 보이고 있지만, 모델 사이즈가 너무 크기 때문에 많은 사람들이 이용하지 못합니다. 이 최신 모델을 사람들이 가볍게 사용하는 모델에 knowledge distillation을 적용하면, 일반화된 모델을 얻을 수 있습니다.

 

Distillation for model compression

 model compression을 위한 distillation은 두 가지 방법을 강조합니다. 첫 번째는 teacher와 student의 입력 image가 동일한 augmentation이 적용되어야 합니다. 두 번째는 엄청나게 긴 학습 시간을 강조합니다.

 

(1) Importance of 'consistent' teaching

 

 knowledge distillation의 방법은 위 그림처럼 4가지 있습니다.

 

(a) Fixed teacher

  •  fix/rs: teacher와 student의 입력 이미지를 augmentation을 적용하지 않고 224로 resize된 이미지를 입력합니다.
  •  fix/cc: teacher은 central crop, student는 random crop image를 입력합니다.
  •  fixic_ens: teacher의 예측은 1024개의 inception crop의 평균을 사용하고, student는 random inception crop을 사용합니다. inception crop이 어떤 것을 의미하는지 잘 모르겠습니다.

(b) Independent noise

  •  ind/rc: teacher와 student 모두 random crop을 사용합니다. 둘 다 서로다른 image를 입력하므로 independent noise라는 명칭을 사용합니다.
  •  ind/ic: random crop 대신에 inception crop을 사용합니다.

 

(c) Consistent teaching

 논문에서 제안하는 방법입니다. teacher와 student가 동일한 이미지를 입력 받아 consistent teaching이라고 부릅니다.

  • same/rc: random crop된 이미지를 각각 다르게 teacher와 student에 입력하는 것이 아니라 하나의 이미지에서 random crop하여 생성된 동일한 이미지를 teacher와 student에 입력합니다.
  • same/ic: 동일한 inception crop 이미지를 teacher와 student에 입력합니다.

 

(d) Function matching

이 방법이 가장 성능이 좋습니다.

  • same/ic,mix: mixup을 적용한 image를 teacher와 student에 입력합니다.

 

 각각의 방법에 따른 실험입니다. same/ic, mix가 성능이 제일 좋습니다.

 

(2) Importance of 'patient' teaching

 Function matching은 hard augmentation 방법입니다. 따라서 모델이 수렴하는데에 오랜 시간이 필요합니다. student가 teacher의 성능에 도달하려면 매우 긴 시간동안 학습이 진행되어야 합니다. function matching 방법으로 짧은 기간동안 학습하면 오히려 기존의 방법보다 성능이 악화됩니다.

 

 

 학습시간이 긴 경우에 student 모델이 결국 teacher의 성능에 도달합니다.

 

Experiment

 imagenet dataset에 대한 실험입니다. function matching 방법에 가장 성능이 좋다는 것을 보여줍니다.

 

 

 Shampoo optimizer을 사용하면 더 빠르게 수렴한다는 것을 보여줍니다.

 

 

 student에 pre-trainied 가중치를 사용하면 초기에는 정확도가 높지만, 결국 랜덤 가중치 초기화 모델이 성능을 따라잡습니다.

 

 

 teacher와 student의 입력 이미지 resolution에 따른 성능비교입니다.

 

 

 out-of-distribution dataset으로 학습한 결과입니다. Food101 dataset으로 knowledge distillation한 결과 Pet dataset에서 30%의 정확도를 보여줍니다. 반면에 Pet이 포함되어 있는 ImageNet dataset은 높은 정확도를 보여줍니다.

 


참고자료

[1] https://arxiv.org/abs/2106.05237

반응형