PacktPublishing / Neural-Network-Projects-with-Python

Neural Network Projects with Python, Published by Packt
MIT License
313 stars 186 forks source link

sigmoid derivative function isn't correct in first python example #4

Open DarthRinzler opened 4 years ago

DarthRinzler commented 4 years ago

The code defines the sigmoid_derivative as:

def sigmoid_derivative(x): return x * (1.0 - x)

But the actual sigmoid derivative is:

def sigmoid_derivative(x): return sigmoid(x) * (1.0 - sigmoid(x))

pcarlisi commented 4 years ago

I thought the same thing at first, but this is not an error.

You'll notice when sigmoid_derivative() is called that the input is self.output and self.layer1, which from the forward feed portion of the object have already applied sigmoid.

May have helped to put a note in the sigmoid_derivative why this is the case.