Guest User

Untitled

a guest
Apr 26th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. import random
  2.  
  3. nn = NeuralNetwork(2,2,1)
  4. inputs = np.array([[0, 0], [1, 0], [0, 1], [1, 1]])
  5. targets = np.array([[0], [1], [1], [0]])
  6. zipped = zip(inputs, targets)
  7. list_zipped = list(zipped)
  8.  
  9. for _ in range(9000):
  10. x, y = random.choice(list_zipped)
  11. nn.train(x, y)
  12.  
  13. output = [nn.feedforward(i) for i in inputs]
  14.  
  15. for i in output:
  16. print("Output ", i)
  17.  
  18. #Output [ 0.1229546] when it should be around 0
  19. #Output [ 0.6519492] ~1
  20. #Output [ 0.65180228] ~1
  21. #Output [ 0.66269853] ~0
  22.  
  23. [ 0.93749991] # should be ~1
  24. [ 0.93314793] # ~1
  25. [ 0.07001175] # ~0
  26. [ 0.06576194] # ~0
Add Comment
Please, Sign In to add comment