Open ngkangtze opened 2 years ago
Hello @ngkangtze
Could you please explain the problem with the code?
# original code in book
inputs = [1,2]
weights = [1,1,1]
def perceptron_predict(inputs, weights):
activation = weights[0]
for i in range(len(inputs)-1):
activation += weights[i+1] * inputs[i]
return 1.0 if activation >= 0.0 else 0.0
print(perceptron_predict(inputs,weights))
In the original code, you return after 1 iteration, which should not be the case. I shifted the indentation of the return line so that it only returns after iterating through all weights.