Example #1
0
    def show_images() -> None:
        random.seed(10)

        dp = DataProvider.load_from_folder(dataset_folder)

        nn = NeuralNet(sizes=[784, 128, 10], epochs=10)
        nn.train(dp.get_train_x(), dp.get_hot_encoded_train_y(),
                 dp.get_test_x(), dp.get_hot_encoded_test_y())

        properly_classified, misclassified = nn.get_properly_classified_and_misclassified_images(
            dp.get_test_x(), dp.get_hot_encoded_test_y())

        print('properly classified')
        plt.imshow(properly_classified[0].reshape(28, 28), cmap=cm.binary)
        plt.show()
        plt.imshow(properly_classified[1].reshape(28, 28), cmap=cm.binary)
        plt.show()
        plt.imshow(properly_classified[2].reshape(28, 28), cmap=cm.binary)
        plt.show()
        plt.imshow(properly_classified[3].reshape(28, 28), cmap=cm.binary)
        plt.show()
        plt.imshow(properly_classified[4].reshape(28, 28), cmap=cm.binary)
        plt.show()

        print('missclasified')
        plt.imshow(misclassified[0].reshape(28, 28), cmap=cm.binary)
        plt.show()
        plt.imshow(misclassified[1].reshape(28, 28), cmap=cm.binary)
        plt.show()
        plt.imshow(misclassified[2].reshape(28, 28), cmap=cm.binary)
        plt.show()
        plt.imshow(misclassified[3].reshape(28, 28), cmap=cm.binary)
        plt.show()
        plt.imshow(misclassified[4].reshape(28, 28), cmap=cm.binary)
        plt.show()