1
錯誤的向後傳播我試圖理解的錯誤的傳播有多麼的落後工作的,所以我想用上面顯示的非常簡單的神經網絡來做到這一點。
我已經做了以下至今:
import numpy as np
def forward_propagation(X, theta_1, theta_2):
z2 = np.dot(X, theta_1)
a2 = sigmoid(z2)
z3 = np.dot(a2, theta_2)
y = sigmoid(z3)
return y
def sigmoid(z):
return 1/(1 + np.exp(-z))
if __name__ == '__main__':
input_layer = 1
hidden_layer = 1
output_layer = 1
# theta_1 = np.random.randn(input_layer, hidden_layer)
# theta_2 = np.random.randn(hidden_layer, output_layer)
theta_1 = np.array(([0.2]))
theta_2 = np.array(([0.1]))
X = np.array(([-5]), dtype=float)
predicted_y = forward_propagation(X, theta_1, theta_2)
print predicted_y
Y = np.array(([1]), dtype=float)
與輸出:
[ 0.50672313]
所以我現在Y的激活,但我完全不明白怎麼可以做向後傳播,並更新參數theta_1
和theta_2
。我一直在試圖與this video跟着,但我完全不明白。我發現其他視頻似乎也做向後誤差傳播方式不同,所以它只是讓我更糊塗了。