Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- nn = NeuralNetwork(2,2,1)
- inputs = np.array([[0, 0], [1, 0], [0, 1], [1, 1]])
- targets = np.array([[0], [1], [1], [0]])
- zipped = zip(inputs, targets)
- list_zipped = list(zipped)
- for _ in range(9000):
- x, y = random.choice(list_zipped)
- nn.train(x, y)
- output = [nn.feedforward(i) for i in inputs]
- for i in output:
- print("Output ", i)
- #Output [ 0.1229546] when it should be around 0
- #Output [ 0.6519492] ~1
- #Output [ 0.65180228] ~1
- #Output [ 0.66269853] ~0
- [ 0.93749991] # should be ~1
- [ 0.93314793] # ~1
- [ 0.07001175] # ~0
- [ 0.06576194] # ~0
Add Comment
Please, Sign In to add comment