示例#1
0
 def learn_test(self):
     net = NeuralNet([1, 3, 1], -1, 1)
     x = [[[-3]], [[2]], [[0]], [[-2]]]
     y = [[[1]], [[1]], [[0]], [[0]]]
     training_set = [x, y]
     J = net.learn(training_set, 5000, 0.5)
     plt.plot(J)
     plt.show()
     res = net.forward_prop([[-3]])
     res_a = res[0]
     a = res_a[len(res_a) - 1]
     print(a)
     print('-----------')
     res = net.forward_prop([[2]])
     res_a = res[0]
     a = res_a[len(res_a) - 1]
     print(a)
     print('-----------')
     res = net.forward_prop([[0]])
     res_a = res[0]
     a = res_a[len(res_a) - 1]
     print(a)
     print('-----------')
     res = net.forward_prop([[-2]])
     res_a = res[0]
     a = res_a[len(res_a) - 1]
     print(a)
     print('-----------')
示例#2
0
import numpy

from neuralnet import NeuralNet
from matplotlib import pyplot as plt

net = NeuralNet([3, 3, 3], -1, 1)
x = [[[1], [2], [3]], [[3], [5], [2]], [[4], [6], [8]]]
y = [[[1], [0], [0]], [[1], [0], [0]], [[0], [1], [0]]]
training_set = [x, y]
J = net.learn(training_set, 1000, 0.5)
plt.plot(J)
plt.show()