Week4
Neural Networks
- 在model中,input是x1⋯xn的features,output是hypothesis function的結果
- x0 input node有時稱為bias unit,其值永遠為1
- 在neural network中,會使用跟classification一樣的logistic function
- 11+e−θTx
- 有時稱之為sigmoid (logistic) activation function
- "theta" parameters有時也稱為"weights"
- 最簡單的表示方式如下:
- [x0x1x2]→[ ]→hθ(x)
- input nodes位於input layer (layer 1),中間經過另一個node (layer 2),最後產出hypothesis function位於output layer
- 在input跟output layer之間可能會有不只一層layer,稱其為hidden layers
- 我們把hidden layer的node稱為activation unit
a(j)i="activation" of unit i in layer jΘ(j)=matrix of weights controlling function mapping from layer j to layer j+1
- 假設有一層hidden layer,會長的像下面這樣:
[x0x1x2x3]→[a(2)1a(2)2a(2)3]→hθ(x)
- 每一個activation node的值如下:
a(2)1=g(Θ(1)10x0+Θ(1)11x1+Θ(1)12x2+Θ(1)13x3)a(2)2=g(Θ(1)20x0+Θ(1)21x1+Θ(1)22x2+Θ(1)23x3)a(2)3=g(Θ(1)30x0+Θ(1)31x1+Θ(1)32x2+Θ(1)33x3)hΘ(x)=a(3)1=g(Θ(2)10a(2)0+Θ(2)11a(2)1+Θ(2)12a(2)2+Θ(2)13a(2)3)
- 每一個layer有它自己的Θ(j),則其dimension的定義如下:
- 假設layer j有sj個unit,layer j+1有sj+1個unit,則Θ(j)的dimension為sj+1×(sj+1)
- +1是因為多考慮bias node x0跟Θ(j)0
- output不須考慮bias node,只有input需要考慮
- 用vector的方式處理:
- 將activation node以vector表示:a(j)=g(z(j))
- 而z(j)=Θ(j−1)a(j−1)
- 若還要計算下一層,就在a(j)中加入一個bias unit
- 就可以計算z(j+1)=Θ(j)a(j)
Examples and Intuitions I
- 一個簡單的例子是以neural network預測x1 AND x2的結果,function會是如下:
[x0x1x2]→[g(z(2))]→hΘ(x)
- Theta matrix則會是:Θ(1)=[−302020]
- sigmoid function在z>4後趨近於1,z < 4後趨近於0
- 所以可以算出如下結果:
hΘ(x)=g(−30+20x1+20x2)x1=0 and x2=0 then g(−30)≈0x1=0 and x2=1 then g(−10)≈0x1=1 and x2=0 then g(−10)≈0x1=1 and x2=1 then g(10)≈1
Examples and Intuitions II
- 在上一節中,AND/OR/NOR都可以無須hidden layer就算出來
- 但XNOR就需要多一層hidden layer才能求出,中間透過AND/OR/NOR的轉換
Multiclass Classification
- 假設最後的結果不是只有2類,而是4類,那可用大小為4的vector來表示:
沒有留言:
張貼留言