import numpy as np
def sigmoid(x):
return 1/(1+np.exp(-x))
def sigmoid_derivative(x):
return x*(1-x)
training_inputs=np.array([[1,2,3],
[4,5,6],
[7,8,9],
[6,7,8]])
training_outputs=np.array([[4,7,1,9]]).T
bias = np.array([[-10,-10,-10,-10]]).T
np.random.seed(1)
synaptic_weights=np.random.random((3,1))
for iteration in range(20000):
input_layer= training_inputs
outputs = sigmoid(np.dot(training_inputs,synaptic_weights))
error = (training_outputs/10) - outputs
adjustments = error*sigmoid_derivative(outputs)
synaptic_weights+=np.dot(input_layer.T,adjustments)
new_output=(sigmoid(np.dot(training_inputs,synaptic_weights)))*10
given_input = np.array([1,2,3])
expected_output= (sigmoid(np.dot(given_input,synaptic_weights)))*10
print(expected_output)
I need to predict the output when i give any 3 input numbers as i tried giving 1,2,3 in last.
But it does not give expected output and always give values around 9 as outputs.
But 1,2,3 input and corresponding output also given as the training set.
Can you please suggest how this model can use for predict values between 1 to 9
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…