1503.02531-Distilling the Knowledge in a Neural Network.md

原來交叉熵還有一個tempature,這個tempature有以下的定義:
git

\[ 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.ui

擁有更高的tempature的系統,其entropy會更高,也就是混亂性更高,方向不趨於一致,而這種不一致性,實際上是一種信息,
能夠描述數據中更多結構的信息。大模型經過強制的正則化,使得最後輸出的信息,entropy更低。所以spa

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.code

也就是在訓練大模型的時候就強制高tempature?可是感受這樣會更加劇這種問題纔對?orm

訓練大模型的時候,正常訓練。其logits使用的時候,用高T,小模型訓練的時候,也使用高T,可是驗證的時候,使用T1.ci

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.get

能夠同時使用softlabel和數據集的label來作訓練,可是softlabel使用不一樣的T的時候,須要將softlabel的loss相應的乘以\(T^2\)it

使用softtarget的好處是,softtarget攜帶了更多的信息,所以能夠用更少的數據來訓練。

多個大模型蒸餾出來的模型,可能比多個模型組合有更好的性能。

多個模型如何蒸餾?用多個模型的輸出,做爲最終蒸餾模型的target,多個target的loss相加。也就是一種多任務學習。

confusion matrix 這個東西能夠被用來探查模型最容易弄錯的是哪些分類。

看錯了,彷佛論文最後只是在討論訓練多個speciallist model,可是並無談到如何把這些models組合回一個大模型。這多是個問題。

相關文章
相關標籤/搜索