Logistic Classification
生活随笔
收集整理的這篇文章主要介紹了
Logistic Classification
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Logistic Classification
?
About
simple but important classifier
- Train your first simple model entirely end to end
- 下載、預處理一些圖片以分類
- Run an actual logistic classifier on images data
- Connect bit of math and code
Detail
Linear Classifier
之所以這樣建模,是因為線性公式是最簡單的數學模型,僅此而已。
- Input: X (e.g. the pixels in an image)
- Apply a linear function to X
- Giant matrix multiply
- Take inputs as a big vector
- Multiply input vector with a matrix, W means weights
- b means biased term
- Machine learning adjust weights and bias for the best prediction
- Output: Y, predictions for per output class
- Y is a vector, represents the probability of each label
- 好的預測中,正確的label的概率應當更接近1
- 往往得到的Y一開始不是概率,而是一些具體值(scores/logits),所以需要轉換,by:
Softmax回歸模型:Wikipedia
Softmax
- 代碼 soft_max.py:Softmax實現與應用
- input的score差異越大(可以全部乘10試試),則輸出的各項label概率差異越大,反之差異越小
- Softmax只關心幾個label之間的概率,不關心具體值
- 機器學習是一個讓預測成功率升高的事情,因此是一個讓score之間差異增大的過程
One hot encoding
正確預測結果應當是只有一個label成立,其他label不成立。這種情況下,預測概率最大的則是最可能的結果。
Example: take this test
- one hot encoding在label很多的情況下not work well,因為output vector到處都是0,很稀疏,因此效率低
- solved by embeddings
- 好處:可以measure我們與理想情況之間的距離(compare two vectors)
分類器輸出:[0.7 0.2 0.1] \<=> 與label對應的真實情況:[1 0 0]
-
Compare two vectors: cross-entropy
-
D(S, L) != D(L, S)
Remember: Label don't log, for label zero
小結
找到合適的W和b,使得S和L的距離D的平均值,在整個數據集n中最小。
最小化cross-entropy
D的平均值即是Training loss,求和和矩陣相乘是個大數據的活。
兩個參數的誤差導致一個呈圓形的loss,所以我們要做的就是找到盡量靠近圓心的weight
機器學習問題變成了一個數值優化
- 解決方法之一:Gradient descent,求導
修改參數,檢查誤差是否變大,往變小的方向修改,直到抵達bottom。
圖中weight是二維的,但事實上可能有極多的weight
總結
以上是生活随笔為你收集整理的Logistic Classification的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 克服过拟合和提高泛化能力的20条技巧和诀
- 下一篇: 卷积神经网络的网络结构——以LeNet-