【论文阅读】Distilling the Knowledge in a Neural Network

论文下载
pytorch复现代码
bib:

@INPROCEEDINGS{Hinton2014Distilling,
  title		= {Distilling the Knowledge in a Neural Network},
  author	= {Geoffrey E. Hinton and Oriol Vinyals and Jeffrey Dean},
  booktitle = {NIPS},
  year      = {2014},
  pages     = {1--9}
}

1. 摘要

  • A very simple way to improve the performance of almost any machine learning algorithm is to train many different models on the same data and then to average their predictions.

  • Unfortunately, making predictions using a whole ensemble of models is cumbersome and may be too computationally expensive to allow deployment to a large number of users, especially if the individual models are large neural nets.

  • Caruana and his collaborators have shown that it is possible to compress the knowledge in an ensemble into a single model which is much easier to deploy and we develop this approach further using a different compression technique.

  • We achieve some surprising results on MNIST and we show that we can significantly improve the acoustic model of a heavily used commercial system by distilling the knowledge in an ensemble ofmodels into a single model.

  • We also introduce a new type of ensemble composed of one or more full models and many specialist models which learn to distinguish fine-grained classes that the full models confuse.

  • Unlike a mixture of experts, these specialist models can be trained rapidly and in parallel.

Notes:

  1. 第一句引入集成学习,在提出集成学习的缺点是太过笨重,进一步提出可以通过压缩模型的方式解决这个问题。这样的叙事方式很流畅,很值得学习。
  2. 本文的贡献,在前人的压缩模型的基础上进一步提出不同的压缩方式,还引入了一种新的集成方式。

2. 算法描述

2.1. 软标签

q i = exp ⁡ ( z i / T ) ∑ j exp ⁡ ( z j / T ) (1) q_i = \frac{\exp(z_i/T)}{\sum_j{\exp(z_j/T)}} \tag{1} qi=jexp(zj/T)exp(zi/T)(1)

T = 1 T = 1 T=1的情况下,一式就是softmax函数,返回类别对应的概率。 在本文中提出的软标签,就是在 T T T取较大值时候计算的概率值。原文描述的是这样的软标签中包含更多的类间信息。一个直观的理解是一张猫的图片,输出百分之八十的概率是猫,百分之十九是狗,百分之1是人,从中可以知道猫和狗相似,和人不太相似。

2.2. simplest form of distillation

在这种情况下,没有使用数据集中的硬标签(hard target)。
L soft = − ∑ i K p i log ⁡ ( q i ) (2) \mathcal{L}_{\text{soft}} = -\sum_i^K{p_i\log(q_i)} \tag{2} Lsoft=iKpilog(qi)(2)

  • K K K表示总的类别数;
  • p i p_i pi表示教师模型的软标签概率, q i q_i qi表示学生模型的软标签概率。

2.3. better way

L = ( 1 − α ) L soft + α L hard (3) \mathcal{L} = (1-\alpha)\mathcal{L}_{\text{soft}} + \alpha \mathcal{L}_{\text{hard}}\tag{3} L=(1α)Lsoft+αLhard(3)
其中,
L hard = − ∑ i K y i log ⁡ ( q i ) (4) \mathcal{L}_{\text{hard}} = -\sum_i^K{y_i\log(q_i)}\tag{4} Lhard=iKyilog(qi)(4)

  • y i y_i yi 表示对应样本的真实标签。

Notice:

  1. 在原文中, α \alpha α值设置较小值。
  2. 由于在计算 L soft \mathcal{L}_{\text{soft}} Lsoft时,需要除以 T T T,导致soft target关联的梯度被缩小了 T 2 T^2 T2倍, L soft \mathcal{L}_{\text{soft}} Lsoft在反向前需要乘以 T 2 T^2 T2,即二式应为
    L soft = − T 2 ∑ i K p i log ⁡ ( q i ) (5) \mathcal{L}_{\text{soft}} = -T^2\sum_i^K{p_i\log(q_i)} \tag{5} Lsoft=T2iKpilog(qi)(5)
将神经网络中的知识进行提取,是一种将模型的信息转化为更为简洁和易于理解形式的过程。 神经网络是一种由许多神经元组成的复杂计算模型,它们通过学习和调整权重来解决各种问题。然而,神经网络通常具有大量的参数和复杂的结构,这使得它们难以解释和应用到其他领域。因此,我们需要一种方法来提取和总结神经网络中的知识,以便更好地理解和应用这些模型。 在进行神经网络知识提取时,有几种常见的方法。一种常见的方法是使用可视化技术,如热力图、激活图和网络结构图等,来可视化网络中不同层的活动模式。这些可视化技术能够帮助我们发现网络中的模式和特征,并从中推断出网络的知识。 另一种方法是使用特征提取技术,如卷积神经网络(CNN)的滤波器、自动编码器的隐藏层和循环神经网络(RNN)的隐状态等,来提取网络学习到的重要特征。这些重要特征可以帮助我们更好地理解网络学习到的信息,并将其应用到其他问题中。 此外,还有一种被称为知识蒸馏的技术,它通过训练一个较小的模型来提取大型模型中的知识。知识蒸馏通过引入目标函数和额外的训练策略,使小模型能够学习到大模型中的重要知识,并在不损失太多性能的情况下将其应用到实际问题中。 总而言之,提取神经网络中的知识是一项重要任务,它能够帮助我们更好地理解和应用这些复杂的模型。通过可视化、特征提取和知识蒸馏等方法,我们能够从神经网络中提取出有用的信息,并将其应用到其他领域或解决其他问题中。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

来日可期1314

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值