Example #1
0
    def test_predict_different_inputs(self):
        bamnet = algorithms.DiscreteBAM()

        data = np.array([[1, 0, 0, 1]])
        target = np.array([[1, 0]])

        bamnet.train(data, target)
        test_vectors = create_vectors(data.reshape(data.size), row1d=True)

        for test_vector in test_vectors:
            np.testing.assert_array_almost_equal(
                bamnet.predict(test_vector)[1], target)
Example #2
0
    def test_predict_different_inputs(self):
        bamnet = algorithms.DiscreteBAM()

        data = np.array([[1, 0, 0, 1]])
        target = np.array([[1, 0]])

        bamnet.train(data, target)
        test_vectors = create_vectors(data.reshape(data.size), row1d=True)

        for test_vector in test_vectors:
            np.testing.assert_array_almost_equal(
                bamnet.predict(test_vector)[1],
                target
            )
Example #3
0
    def test_reconstruct_different_inputs(self):
        ojanet = algorithms.Oja(minimized_data_size=1,
                                verbose=False,
                                step=0.01)

        data = np.array([[1, 2, 3]]).T
        target = np.array([[1, 2, 3]]).T
        input_vector = data.ravel()

        ojanet.train(data, epsilon=0.1)

        test_vectors = create_vectors(input_vector)

        for i, test_vector in enumerate(test_vectors, start=1):
            np.testing.assert_array_almost_equal(
                ojanet.reconstruct(test_vector), target, decimal=1)
Example #4
0
    def test_reconstruct_different_inputs(self):
        ojanet = algorithms.Oja(minimized_data_size=1, verbose=False,
                                step=0.01)

        data = np.array([[1, 2, 3]]).T
        target = np.array([[1, 2, 3]]).T
        input_vector = data.ravel()

        ojanet.train(data, epsilon=0.1)

        test_vectors = create_vectors(input_vector)

        for i, test_vector in enumerate(test_vectors, start=1):
            np.testing.assert_array_almost_equal(
                ojanet.reconstruct(test_vector),
                target,
                decimal=1
            )