Answer the question
In order to leave comments, you need to log in
What is wrong with my python code?
def dot(v,w):
return sum(v_i*w_i for v_i, w_i in zip(v,w))
def feed_forward(neural_network, input_vector):
outputs = []
for layer in neural_network:
input_with_bias = input_vector + [1] # add a bias input
output = [dot(neuron, input_with_bias) # compute the output
for neuron in layer] # for this layer
outputs.append(output) # and remember it
# the input to the next layer is the output of this one
input_vector = output
return outputs
random.seed(0)
num_layer = 2
num_neuron = 3
count_weight = 3
input_layer = [[random.random() for _ in range(count_weight)]
for __ in range(num_neuron)]
output_layer = [random.random() for _ in range(count_weight+1)]
neurolink = [input_layer, output_layer]
input_vector = [1,0,1]
feed_forward(neurolink, input_vector)
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