2017年4月15日 星期六

Training A Simple Classifier - Learning Rate

承續上一篇,Training A Simple Classifier - Algorithm。我們的問題是,想修改程式,讓Finale Refined Line不要太偏向於Caterpillar。本篇,採用Learning Rate,改善這種情況。

下面步驟,會先產生Initial Line,然後用Learning Rate修正Refined Line與Final Refined Line。其過程,和上篇,Training A Simple Classifier - Algorithm,類似,細節就不多說了。這裡,著重在Learning Rate的使用方式

Initial Line

y = A * x
A = 0.25

Refined Line for Ladybird (3, 1)

Desired Target = 1.1
1.1 = (0.25 + △A) * 3
△A = (1.1 / 3) - 0.25 = 0.1167

我們不希望△A變化太大,故設定Learning Rate,L = 0.5,來修正△A。
△A = L * △A = 0.5 * 0.1167 = 0.0583

A = A + △A = 0.25 + 0.0583 = 0.3083
Refined Line: y = 0.3083 x

Final Refined Line for Caterpillar (1, 3)

Desired Target = 2.9
2.9 = (0.3083 + △A) * 1
△A = 2.9 - 0.3083 = 2.5917

△A = L * △A = 0.5 * 2.5917 = 1.2958
A = A + △A = 0.3083 + 1.2958 = 1.6042
Final Refined Line: y = 1.6042 x

然後,把Initial Line、Refine Line、Final Refined Line的演化過程,表達為下圖:



我們發現,因為Learning Rate設為0.5,導致Refined Line,還是在Ladybird下面。但對於Final Refined Line而言,此線畫在Caterpillar與Ladybird的中間,比較不偏向任何一方。這就是Learning Rate的作用。

-Count

沒有留言:

張貼留言