[英]Neural Network in Python - Having trouble with weight matrix shapes and back prop
[英]Trouble in understanding how the dimension of the weight matrix or theta matrix is 3X4?
Theta(權重)矩陣的大小為(輸出 x 輸入)。
輸入包括偏置單元。
output 不包括偏置單元。
在圖中,它將是 [3 x (3+1)]。 這里額外的 1 是添加到輸入的偏置單元。
因此,簡單的公式是 S(j+1) X (Sj + 1),即 3 x (3+1)
從圖中我們了解到:
例如,在第一層,j=1,節點數,sj=3。
在所示的架構中,我們有三層。
現在,theta 是層之間的權重矩陣。 Theta 也稱為權重或參數。我們有三層,因此有兩個矩陣,theta1 和 theta2。
weight_matrix1(Theta1) 映射在輸入層和隱藏層之間
weight_matrix2(Theta2) 映射在隱藏層和 output 層之間
按公式:
權重矩陣 1 的維度(在 s2 和 s1 之間)= s2 * (s1+1) = 3 *(3+1) = 3 * 4
權重矩陣 2 的維度(在 s3 和 s2 之間)= s3 * (s2+1) = 1 *(3+1) = 1 * 4
我們加 1 來解釋偏置層 x0。 對於矩陣乘法,matrix1 中的行數應該等於 matrix2 中的列數。 在這個例子中,我們知道 layer1 的維度和 layer 2 的維度,我們從中計算 weight_matrix theta 的維度。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.