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跟着,但我完全不明白。我发现其他视频似乎也做向后误差传播方式不同,所以它只是让我更糊涂了。