DEV Community


Discussion on: Build a flexible Neural Network with Backpropagation in Python

dhlpradip profile image

Thanks for the great tutorial but how exactly can we use it to predict the result for next input? I tried adding 4,8 in the input and it would cause error as:

Traceback (most recent call last):
[[0.5 1. ]
[0.25 0.55555556]
[0.75 0.66666667]
[1. 0.88888889]]
Actual Output:
File "D:/", line 58, in
print ("Loss: \n" + str(np.mean(np.square(y - NN.forward(X))))) # mean sum squared loss
Predicted Output:
ValueError: operands could not be broadcast together with shapes (3,1) (4,1)

Process finished with exit code 1

tanaydin profile image
tanaydin sirin

after training done, you can make it like

Q = np.array(([4, 8]), dtype=float)
print "Input: \n" + str(Q)
print "Predicted Output: \n" + str(NN.forward(Q))