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)
Выдаёт вот такую ошибку
Traceback (most recent call last):
File "nlone.py", line 37, in
feed_forward(neurolink, input_vector)
File "nlone.py", line 17, in feed_forward
for neuron in layer]
File "nlone.py", line 17, in
for neuron in layer]
File "nlone.py", line 8, in dot
return sum(v_i*w_i for v_i, w_i in zip(v,w))
TypeError: zip argument #1 must support iteration