def test_multilayer_perceptron_train(self):
        # mlnn = MultiLayerNeuralNetwork([2, 2, 1], threshold=0.5, learning_coefficient=0.5, sigmoid_alpha=5)
        mlnn = MultiLayerNeuralNetwork([2, 4, 1], threshold=0.5, learning_coefficient=0.5, sigmoid_alpha=5, print_error=False)
        #mlnn = MultiLayerNeuralNetwork([2, 4, 4, 1], threshold=0.5, learning_coefficient=0.5, sigmoid_alpha=5)

        train_data = [
                [[0,0],[1]],
                [[1,0],[0]],
                [[0,1],[0]],
                [[1,1],[1]],
                ]

        # train
        mlnn.train(train_data)

        # print train_data
        # print mlnn.weights
        # print mlnn.predict([0, 0])
        # print mlnn.predict([1, 0])
        # print mlnn.predict([0, 1])
        # print mlnn.predict([1, 1])
        assert mlnn.predict([0, 0]) > mlnn.predict([1, 0])
        assert mlnn.predict([0, 0]) > mlnn.predict([0, 1])
        assert mlnn.predict([1, 1]) > mlnn.predict([1, 0])
        assert mlnn.predict([1, 1]) > mlnn.predict([0, 1])
    def test_multilayer_perceptron_predict(self):
        mlnn = MultiLayerNeuralNetwork([2, 1], threshold=1.0, learning_coefficient=1.0, sigmoid_alpha=1.0, print_error=False)

        mlnn.weights = {1: np.array([[-1, 1, 1]])}
        assert mlnn.predict([0, 0]) == [1 / (1 + math.e ** 1)]
        assert mlnn.predict([0, 1]) == [0.5]
        assert mlnn.predict([1, 0]) == [0.5]
        assert mlnn.predict([1, 1]) == [1 / (1 + math.e ** -1)]

        assert mlnn.predict_all_layer([0, 0]) == [[0, 0],[1 / (1 + math.e ** 1)]]
        assert mlnn.predict_all_layer([0, 1]) == [[0, 1],[0.5]]
        assert mlnn.predict_all_layer([1, 0]) == [[1, 0],[0.5]]
        assert mlnn.predict_all_layer([1, 1]) == [[1, 1],[1 / (1 + math.e ** -1)]]

        # assert mlnn.predict([0, 0], 1) == [1 / (1 + math.e ** 1)]
        # assert mlnn.predict([0, 1], 1) == [0.5]
        # assert mlnn.predict([1, 0], 1) == [0.5]
        # assert mlnn.predict([1, 1], 1) == [1 / (1 + math.e ** -1)]

        # assert mlnn.predict([0, 0], 0) == [0, 0]
        # assert mlnn.predict([0, 1], 0) == [0, 1]
        # assert mlnn.predict([1, 0], 0) == [1, 0]
        # assert mlnn.predict([1, 1], 0) == [1, 1]

        # XORが計算できることを重み指定して確認したい.
        mlnn.weights = {1: np.array([[-0.5, 1, -1], [-0.5, -1, 1]]) ,
                        2: np.array([[-0.5, 1, 1],])}