Advertisement
here2share

# b_numpy_only_neural.py

Nov 21st, 2018
482
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. # b_numpy_only_neural.py
  2.  
  3. from numpy import exp, array, random, dot
  4. training_set_inputs = array([[0, 0, 1], [1, 1, 1], [1, 0, 1], [0, 1, 1]])
  5. training_set_outputs = array([[0, 1, 1, 0]]).T
  6. random.seed(1)
  7. synaptic_weights = 2 * random.random((3, 1)) - 1
  8. for iteration in xrange(10000):
  9.     output = 1 / (1 + exp(-(dot(training_set_inputs, synaptic_weights))))
  10.     synaptic_weights += dot(training_set_inputs.T, (training_set_outputs - output) * output * (1 - output))
  11. print 1 / (1 + exp(-(dot(array([1, 0, 0]), synaptic_weights))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement