def fullTest(): trainImages, labels, testImages = loadImages() per = Perceptron(64, 8, 8) per.train(trainImages, labels, 10000) results = per.test(testImages) print(results)
def exercise6(): print("\nExercise 6: Testing\n") perceptron = Perceptron(4, 2, 2) trainImages = [ np.array([[1, 0], [0, 0]]), np.array([[0, 0], [0, 1]]), np.array([[1, 1], [0, 0]]), np.array([[0, 1], [0, 1]]) ] labels = [1, -1, 1, -1] perceptron.train(trainImages, labels, 10) testImages = [ np.array([[1, 0], [0, 0]]), np.array([[0, 0], [0, 1]]), np.array([[1, 1], [0, 0]]), np.array([[0, 1], [0, 1]]) ] expectedResults = [1, -1, 1, -1] print(testTesting(perceptron, testImages, expectedResults)) testImages = [ np.array([[0, 0], [1, 0]]), np.array([[0, 0], [1, 1]]), np.array([[1, 1], [1, 0]]), np.array([[0, 1], [1, 1]]) ] expectedResults = [0, -1, 1, -1] print(testTesting(perceptron, testImages, expectedResults))
def fullTest(): trainImages, labels, testImages = loadImages() per = Perceptron(64, 8, 8) per.train(trainImages, labels, 10000) results = per.test(testImages) for image, result in zip(testImages, results): cv2.imshow("test", image * 255) print(result) cv2.waitKey(0) print(results)