How to build a simple neural network in 9 lines of Python code

Ian Kelly ian.g.kelly at gmail.com
Tue Jun 27 23:17:44 EDT 2017


On Tuesday, June 27, 2017, Steve D'Aprano <steve+python at pearwood.info>
wrote:

> On Wed, 28 Jun 2017 02:23 am, Sam Chats wrote:
>
> >
> https://medium.com/technology-invention-and-more/how-to-
> build-a-simple-neural-network-in-9-lines-of-python-code-cc8f23647ca1
>
>
> The derivative of the sigmoid curve given is completely wrong.
>
>     def __sigmoid(self, x):
>         return 1 / (1 + exp(-x))
>
>     def __sigmoid_derivative(self, x):
>         return x * (1 - x)
>
>
> Should be:
>
>     def __sigmoid_derivative(self, x):
>         return exp(x) / (1 + exp(x))**2
>
>
>
> http://mathworld.wolfram.com/SigmoidFunction.html
>
>
Actually, it's not stated clearly but x is not the same in each function.
The return value of sigmoid is the input of sigmoid_derivative. The article
that you linked confirms that this identity holds.



More information about the Python-list mailing list