[Notes]Knowledge distillation: A good teacher is patient and consistent

  • 2021 年 6 月 22 日
  • AI

模型加速三板斧:

  • 量化
  • 減枝
  • distill

這篇論文做的是 distillation 相關的試驗驗證,而且是 Google 不差錢風。

這篇論文的好處是,沒任何額外的 trick ,拿來就可以用。看別人燒錢在大規模數據上的結論,省自己的錢。

The apparent simplicity of our findings

兩個 principles :

  1. Teacher and student should process the exact same input image viewsor, more specifically, same crop and augmentations.
  2. We want the functions to match on alarge number of support points to generalize well.

With this in mind, we experimentally demonstrate that consistent image views, aggressive augmentations and very long training schedulesare the key to makemodel compression via knowledge distillationwork well in practice.

論文中一些關於 distillation 的相關結論:

  1. 數據增強要保證 teacher(T), student(S) 兩者一致。
  2. 訓練 epoch 要增大,文中的直接用的 10k epoch,沒有發生 overfit(沒有 overfit,那就是 deep learning 的天堂)。
  3. 可以用高清輸入的 T 來訓練 S,但是看文中的精度,提升性價比不高,要消耗太多算力。
  4. Pretrained 的模型反而不如直接 from scratch(也不意外,現在很多場景 pretrained 其實作用不大了,尤其現在的 AI 公司,私有數據規模都已經很大了,畢竟 pretrained 的也只是一套「還可以」的參數)。
  5. 異構的模型一樣可以直接 distill,mobilenet、resnet 隨便訓。
  6. OOD 的數據之間 distill 效果不理想(這也不意外,畢竟不是通用特徵,但是如果你有個”上帝”數據集,裡面什麼都有,那肯定照樣有效果)。

自己的民科

  1. 有時候簡單粗暴比一堆 trick 有效多了。在 deep learning 里,可能之前的很多工作隨著數據的增加都會變得失去意義。
  2. 在工業界,其實 distill 比單純的追 sota 演算法更加重要,畢竟 distill 是個訓練框架。一些 sota 演算法為了刷指標可能有一些場景限制、不考慮實用等等。何況,用了 distill,一樣可以嘗試把 sota 模型蒸餾到自己樸素的 resnet、Faster-RCNN、Yolo上。
  3. 對於工業界訓練,數據規模上到 m 級別以上後,就可以開始訓專家模型了。專家模型後面也可以用 ensemble、cascade子分類器來進一步通過蒸餾來指導線上模型的訓練。