Skip to content

Commit

Permalink
chore: update some details
Browse files Browse the repository at this point in the history
  • Loading branch information
HarleysZhang committed Mar 14, 2023
1 parent 09b53e4 commit 9d02ccc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions 7-model_compression/卷积网络压缩方法总结.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ $$min \left \| W -\alpha B \right \|^{2}$$
+ 建议使用 4bit 及以下的 `activation bit`, 过高带来的精度收益变小, 而会显著提高 inference 计算量

## 五,知识蒸馏
> 本文只简单介绍这个领域的开篇之作-Distilling the Knowledge in a Neural Network,这是蒸 "logits"方法,后面还出现了蒸 "features" 的论文。想要更深入理解,中文博客可参考这篇文章-[知识蒸馏是什么?一份入门随笔](https://zhuanlan.zhihu.com/p/90049906)
> 本文只简单介绍这个领域的开篇之作-Distilling the Knowledge in a Neural Network,这是蒸 "logits"方法,后面还出现了蒸 "features" 的论文。
知识蒸馏[knowledge distillation](https://link.zhihu.com/?target=https%3A//arxiv.org/abs/1503.02531)),是迁移学习(transfer learning)的一种,简单来说就是训练一个大模型(teacher)和一个小模型(student),将庞大而复杂的大模型学习到的知识,通过一定技术手段迁移到精简的小模型上,从而使小模型能够获得与大模型相近的性能。
所谓知识蒸馏[knowledge distillation](https://link.zhihu.com/?target=https%3A//arxiv.org/abs/1503.02531)),其实是迁移学习(transfer learning)的一种,通俗理解就是训练一个大模型(teacher)和一个小模型(student),将庞大而复杂的大模型学习到的知识,通过一定技术手段迁移到精简的小模型上,从而使小模型能够获得与大模型相近的性能。

在知识蒸馏的实验中,我们先训练好一个 `teacher` 网络,然后将 `teacher` 的网络的输出结果 $q$ 作为 `student` 网络的目标,训练 `student` 网络,使得 `student` 网络的结果 $p$ 接近 $q$ ,因此,`student` 网络的损失函数为 $L = CE(y,p)+\alpha CE(q,p)$。这里 `CE` 是交叉熵(Cross Entropy),$y$ 是真实标签的 `onehot` 编码,$q$ 是 `teacher` 网络的输出结果,$p$ 是 `student` 网络的输出结果。

Expand All @@ -173,7 +173,7 @@ $$q_{i} = \frac{z_{i}/T}{\sum_{j}z_{j}/T}$$

所以,可以知道 `student` 模型最终的损失函数由两部分组成:

+ 第一项是由小模型的预测结果与大模型的“软标签”所构成的交叉熵(cross entroy);
+ 第一项是由小模型的预测结果与训练好的大模型的“软标签”所构成的交叉熵(cross entroy);
+ 第二项为预测结果与普通类别标签的交叉熵。

这两个损失函数的重要程度可通过一定的权重进行调节,在实际应用中,`T` 的取值会影响最终的结果,一般而言,较大的 T 能够获得较高的准确度,T(蒸馏温度参数) 属于知识蒸馏模型训练超参数的一种。**T 是一个可调节的超参数、T 值越大、概率分布越软(论文中的描述),曲线便越平滑**,相当于在迁移学习的过程中添加了扰动,从而使得学生网络在借鉴学习的时候更有效、泛化能力更强,这其实就是一种抑制过拟合的策略。知识蒸馏的整个过程如下图:
Expand Down

0 comments on commit 9d02ccc

Please sign in to comment.