Answer the question
In order to leave comments, you need to log in
How to fix a bug in numpy calculations?
Here is the whole code:
import numpy as np
i1 = np.array();
out = [-1,1,0,1,1,1];
np.random.seed(1);
syn0 = 2*np.random.random((2,3)) - 1
syn1 = 2*np.random.random((3,1)) - 1
for iter in range(60000):
l0 = i1;
l1 = np.tanh(np.dot(l0,syn0));
l2 = np.tanh(np.dot(l1,syn1));
l2_error = out - l2;
if (iter % 10000) == 0:
print( "Error:" + str(np.mean(np.abs(l2_error))));
l2_delta = l2_error*np.tanh(l2);
l1_error = l2_delta.dot(syn1.T);
l1_delta = l1_error * np.tanh(l1);
syn1 += l1.T.dot(l2_delta);
syn0 += l0.T.dot(l1_delta);
print(l2);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question