【发布时间】:2016-11-21 19:35:47
【问题描述】:
我试图了解错误的反向传播是如何工作的,因此我尝试使用上面显示的非常简单的神经网络来做到这一点。
到目前为止,我已经完成了以下工作:
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,但我完全不明白。我发现的其他视频似乎也以不同的方式反向传播错误,所以这让我更加困惑。
【问题讨论】:
标签: python neural-network backpropagation