둔비의 공부공간
Class Attention Transfer Based Knowledge Distillation 본문
CVPR 2023
https://arxiv.org/abs/2304.12777
Class Attention Transfer Based Knowledge Distillation
Previous knowledge distillation methods have shown their impressive performance on model compression tasks, however, it is hard to explain how the knowledge they transferred helps to improve the performance of the student network. In this work, we focus on
arxiv.org
한동안 ACL2024 paper를 작성하느라 바빠서, 논문읽고 블로그에 정리를 못했다.
석사 2년차가 된 올해는 더 열심히 살아야겠다.
이 논문은 최근에 공개된 CAM기반의 Knowledge Distillation인데, 기존 CAM과 다르게 feed forward 한번에 visualization까지 가능하다.
다만, KD부분의 성능측정은 kd_lambda 값 튜닝이 심하다. (0.7 ~ 600) * cam_loss 감안하고 보면 좋을 것 같다.
Method
'기존 CNN의 마지막 fully connected layer (FC Layer)를 1x1 Conv로 변환하여 나온 Feature를 CAM으로 볼 수 있다!' 이다.
쉽게 설명하기 위해서 아래 흐름대로 정리해보면 다음과 같다.
기존 CNN
- 마지막 Conv Layer
- (BS, C, H, W)
- POOLING
- (BS, C, 1, 1)
- FC Layer
- (BS, K class_num)
Converted Structrue
- 마지막 Conv Layer
- (BS, C, H, W)
- 1x1 Conv Layer
- CAM (BS, K class_num, H, W)
- POOLING
- (BS, K class_num)
이때, fc layer는 (in_features=C, out_features=K class_num)이고
1x1 conv는 (in_channels=C, out_channels=K class_num, kernel=1,stride=1) 이다.
그러므로, fc layer의 weight를 그대로 1x1 conv로 변환하여 사용이 가능하다.
pretrained_dict["conv_1x1.weight"] = model_teacher.state_dict()[
"fc.weight"
].view(
model_teacher.fc.out_features,
model_teacher.fc.in_features,
1,
1,
)
위와 같은 과정으로, 추가적인 학습없이 한번의 feed forward로 CAM을 만들 수 있는 아키텍쳐로 변경이 가능했다.
이러한 방법으로 생성된 CAM을, student에게 넘겨주는 CAT-KD를 제안했다.
Experiments
모든 CAM이 정말 의미있는 Visualization이 되는가?
첫번째 Class (Bee)에 대한 CAM을 보면, bee와 tiger가 서로 다른 class임에도 불구하고, 비슷한 CAM을 보인다.
두번째 Class (Kangaroo)역시, rabit과 fox도 비슷한 CAM을 보였다.
이러한 상황은 단순하게 top1 class (Bee, Kangaroo, Bear)를 Visualization하여 XAI할때는 상관이 없지만,
이를 Distillation하는 상황에서, 저렇게 이상하게 나온 CAM을 distillation하는 의미가 있을까? 하는 실험을 아래서 진행한다.
몇 개의 CAM을 Distillation하는 것이 좋을까?
논문의 저자들은 상위 N개, 하위 N개의 Class중 몇개를 넘겨주는 것이 Distillation 성능이 좋을까? 에 대한 실험을 진행했다.
결론적으로는 '전부 다 넘겨주는 것이 좋다' 이다.
의미가 없이 다 비슷하게 나온 CAM 조차도 다 넘겨주는 것이 성능 향상에 도움이 되는 것을 확인했다.
그렇다면, CAM을 어떻게 넘겨주는 것이 좋은가?
저자들은 CAM(BS, K, 8, 8)의 feature를 distillation할때, 그대로 넘겨주는 것은 좋지 않았다고 이야기한다.
큰 8x8 크기의 CAM을 넘겨주는 것이 디테일로 인해 성능이 좋을 것 같지만, 모델별 capacity로 인해 CAM의 디테일이 다르기에
이러한 디테일을 적절하게 뭉개는 것이 성능향상에 도움이 됐다고 한다.
적절하게 뭉개기 위해, 저자들은 Adaptive Avg Pooling을 사용하여 2x2 크기로 변환후에 distillation했다.
다른 KD Methods와 성능을 비교하자.
CIFAR100에 대해서 비교를 해보면, 대체적으로 좋은 성능을 보인다.
이는 특히 다른 architectures에서 성능이 높은 것을 볼 수 있다.
'Papers > Compression' 카테고리의 다른 글
Cumulative Spatial Knowledge Distillation for Vision Transformer (0) | 2024.04.11 |
---|---|
One-for-All: Bridge the Gap Between Heterogeneous Architectures in Knowledge Distillation (0) | 2024.04.07 |
Curriculum Temperature for Knowledge Distillation (0) | 2023.12.28 |
Multi-level Logit Distillation (1) | 2023.12.08 |
DOT: A Distillation-Oriented Trainer (1) | 2023.11.23 |