How to build a simple neural network in 9 lines of Python code
Steve D'Aprano
steve+python at pearwood.info
Tue Jun 27 21:14:59 EDT 2017
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
I wish these neural networks would give a tutorial on how to do something
non-trivial where:
- your training data is not just a couple of bits;
- the function you want the neural network to perform is non-trivial.
E.g. I have a bunch of data:
['cheese', 'pirate', 'aardvark', 'vitamin', 'egg', 'moon']
and a set of flags:
[True, False, True, True, False, True]
and I want the network to predict that:
'calcium' -> False
'aluminium' -> True
'wood' -> True
'plastic' -> False
(The function is, "is there a duplicated vowel?")
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
More information about the Python-list
mailing list