After discussing with Chong Wang of IIM, I have understood completely http://deeplearning.stanford.edu/wiki/index.php/Softmax_Regression. This is a good reference. The matlab code can be found in my computer by searching "Softmax". It is in "matlab\work\classifier\Softmax".
在 Logistic Regression 里就可以看到它 。具體來(lái)說(shuō),Softmax 函數(shù) 定義如下:
它在 Logistic Regression 里其到的作用是講線性預(yù)測(cè)值轉(zhuǎn)化為類(lèi)別概率:假設(shè) 是第 個(gè)類(lèi)別的線性預(yù)測(cè)結(jié)果,帶入 Softmax 的結(jié)果其實(shí)就是先對(duì)每一個(gè) 取 exponential 變成非負(fù),然后除以所有項(xiàng)之和進(jìn)行歸一化,現(xiàn)在每個(gè) 就可以解釋成觀察到的數(shù)據(jù) 屬于類(lèi)別 的概率,或者稱作似然 (Likelihood)。
然后 Logistic Regression 的目標(biāo)函數(shù)是根據(jù)最大似然原則來(lái)建立的,假設(shè)數(shù)據(jù) 所對(duì)應(yīng)的類(lèi)別為 ,則根據(jù)我們剛才的計(jì)算最大似然就是要最大化 的值 。后面這個(gè)操作就是 caffe 文檔里說(shuō)的 Multinomial Logistic Loss,具體寫(xiě)出來(lái)是這個(gè)樣子:
而 Softmax-Loss 其實(shí)就是把兩者結(jié)合到一起,只要把 的定義展開(kāi)即可
沒(méi)有任何 fancy 的東西。
注意點(diǎn):區(qū)別Softmax 函數(shù)和Softmax-Loss
reference:
http://freemind.pluskid.org/machine-learning/softmax-vs-softmax-loss-numerical-stability/