I am having problem in the Matrix multiplication of my Python neural network. Being still a High schooler, I know next to nothing about MM except a couple of tutorials. My Neural network was working fine when my inputs were like ([0,1,1]...) but when I changed them to doubles, my MM is going wrong(No Output)
# The initialization import numpy as np iterations = int(0) #TO THE CODING=> def sigmoid(x): return 1/(1 + np.exp(-x)) #The function- 2 def Sigmoid_Derivative(x): return sigmoid(x) * (1-sigmoid(x)) Training_inputs = np.array([[0,0], [1,1], [1,0], [0,1]]) # 4 rows * 2 columns Training_outputs = np.array([[1, 1, 0, 0]]).T # 2 rows * 2 columns Correct_Outputs = np.array([[,, ,]]) np.random.seed(1) synaptic_weights = np.random.random((2, 1)) - 1 print ("Random starting synaptic weight:") print (synaptic_weights) for iteration in range(20000): Input_Layer = Training_inputs Outputs = sigmoid(np.dot(Input_Layer, synaptic_weights)) erorr = Training_outputs - Outputs adjustments = erorr * Sigmoid_Derivative(Outputs) synaptic_weights += np.dot(Input_Layer.T, adjustments) Rounder = np.around([np.array(Outputs)],decimals = 2,) Final_Outputs = Rounder.astype(int) iterations += 1 if np.array_equal(Final_Outputs, Correct_Outputs): print ("Synaptic weights after trainig:") print (synaptic_weights) print ("Outputs after training: ") print (Outputs) print ("NO. of iterations required: ",iterations) break else: continue
P.S The if-else iteration checker was my own coding. Maybe it might have a potential implication.