Hello!!
I’m following the video Theory of Neural Networks - Deep Learning Without Frameworks and I’m trying to complete the second example and I write the code as follows:
import numpy as np
weights = np.array([0.7, 0.2, -0.5])
alpha = 0.1
streetlights = ([[0, 0, 1],
[0, 1, 1],
[0, 0, 1],
[1, 1, 1],
[0, 1, 1],
[1, 0, 1]])
walk_vs_stop = np.array([0, 1, 0, 1, 1, 0])
for iteration in range(40):
error_for_all_lights = 0
for row_index in range (len(walk_vs_stop)):
input = streetlights[row_index]
goal_prediction = walk_vs_stop[row_index]
prediction = input.dot(weights)
error = (prediction - goal_prediction) ** 2
error_for_all_lights += error
delta = prediction - goal_prediction
weights = weights - (alpha *(input * delta))
print ("Prediction:" + str(prediction))
print ("Weights:" + str(weights))
print ("Error:" + str(error))
I received the following error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-7-afbdd6a5aaed> in <module>()
19 goal_prediction = walk_vs_stop[row_index]
20
---> 21 prediction = input.dot(weights)
22 error = (prediction - goal_prediction) ** 2
23 error_for_all_lights += error
AttributeError: 'list' object has no attribute 'dot'
I’m trying to solve it by my own but I’m not able to see where the problem is. Can you tell me, please, where is the mistake?
Thank you so much!!!