zoukankan      html  css  js  c++  java
  • 1503.02531-Distilling the Knowledge in a Neural Network.md

    原来交叉熵还有一个tempature,这个tempature有如下的定义:

    $$ q_i=frac{e^{z_i/T}}{sum_j{e^{z_j/T}}} $$

    其中T就是tempature,一般这个T取值就是1,如果提高:
    In [6]: np.exp(np.array([1,2,3,4])/2)/np.sum(np.exp(np.array([1,2,3,4])/2))
    Out[6]: array([0.10153632, 0.1674051 , 0.27600434, 0.45505423])
    
    In [7]: mx.nd.softmax(mx.nd.array([1,2,3,4]))
    Out[7]: 
    
    [0.0320586 0.08714432 0.23688284 0.6439143 ]
    <NDArray 4 @cpu(0)>
    

    也就是

    Using a higher value for T produces a softer probability distribution over classes.

    拥有更高的tempature的系统,其entropy会更高,也就是混乱性更高,方向不趋于一致,而这种不一致性,其实是一种信息,
    可以描述数据中更多结构的信息。大模型通过强制的正则化,使得最后输出的信息,entropy更低。因此

    Our more general solution, called “distillation”, is to raise the temperature of the final softmax until the cumbersome model produces a suitably soft set of targets. We then use the same high temperature when training the small model to match these soft targets. We show later that matching the logits of the cumbersome model is actually a special case of distillation.

    也就是在训练大模型的时候就强制高tempature?但是感觉这样会更加重这种问题才对?

    训练大模型的时候,正常训练。其logits使用的时候,用高T,小模型训练的时候,也使用高T,但是验证的时候,使用T1.

    In the simplest form of distillation, knowledge is transferred to the distilled model by training it on a transfer set and using a soft target distribution for each case in the transfer set that is produced by using the cumbersome model with a high temperature in its softmax. The same high temperature is used when training the distilled model, but after it has been trained it uses a temperature of 1.

    可以同时使用softlabel和数据集的label来做训练,但是softlabel使用不同的T的时候,需要将softlabel的loss相应的乘以(T^2)

    使用softtarget的好处是,softtarget携带了更多的信息,因此可以用更少的数据来训练。

    多个大模型蒸馏出来的模型,可能比多个模型组合有更好的性能。

    多个模型如何蒸馏?用多个模型的输出,作为最终蒸馏模型的target,多个target的loss相加。也就是一种多任务学习。

    confusion matrix 这个东西可以被用来探查模型最容易弄错的是哪些分类。

    看错了,似乎论文最后只是在讨论训练多个speciallist model,但是并没有谈到如何把这些models组合回一个大模型。这可能是个问题。

  • 相关阅读:
    「小程序JAVA实战」小程序视频封面处理(48)
    「小程序JAVA实战」小程序视频处理工具ffmpeg(47)
    「小程序JAVA实战」小程序上传短视频(46)
    微信小程序跳转navigateTo与redirectTo
    微信小程序中this关键字使用技巧
    ***电商数据库设计参考:ecshop数据库+订单表结构等
    MYSQL中'TYPE=MyISAM'错误的解决方案
    PHP实现执行定时任务的几种思路详解
    PHP定时器实现每隔几秒运行一次
    ***LINUX添加PHP环境变量:CentOS下将php和mysql命令加入到环境变量中
  • 原文地址:https://www.cnblogs.com/dwsun/p/9297200.html
Copyright © 2011-2022 走看看