请教各位,我想创造一个神经网络包含
3 inputs
2 hidden nodes
1 output
import numpy as np
x = np.array([0.5, -0.2, 0.1])
y = np.array([0.4])
test_w_i_h = np.array([[0.1, -0.2],
[0.4, 0.5],
[-0.3, 0.2]])
test_w_h_o = np.array([[0.3],
[-0.1]])
delta_weights_i_h = np.zeros(test_w_i_h.shape)
delta_weights_h_o = np.zeros(test_w_h_o.shape)
activation_function = lambda x : 1/(1 + np.exp(-x))
hidden_inputs = np.dot(x, test_w_i_h)
hidden_outputs = activation_function(hidden_inputs)
final_inputs = np.dot(hidden_outputs, test_w_h_o)
final_outputs = activation_function(final_inputs)
error = y - final_outputs
hidden_error = error * final_outputs * (1 - final_outputs) * test_w_h_o
output_error_term = error * final_outputs * (1 - final_outputs)
hidden_error_term =
hidden_outputs[:, None] * (1 - hidden_outputs[:, None]) * hidden_error
delta_weights_i_h += hidden_error_term.T * x[:, None]
delta_weights_h_o += output_error_term * hidden_outputs[:,None]
但是在更新 Weight 时却总是与预期答案不相符,想请问我是哪里写错了?
提供p币 100 拜托大家了