Esempio n. 1
0
    def test_histogram(self):
        images = xp.array([[[0, 1, 1, 3], [3, 1, 2, 2], [2, 0, 1, 2],
                            [0, 1, 1, 1]],
                           [[2, 0, 1, 2], [1, 3, 0, 1], [2, 2, 2, 3],
                            [1, 3, 3, 1]]])
        expected = xp.array([[1, 2, 0, 1, 0, 1, 2, 1, 2, 1, 1, 0, 0, 3, 1, 0],
                             [1, 1, 1, 1, 1, 2, 1, 0, 0, 1, 2, 1, 0, 1, 1, 2]])
        pcanet = PCANet(None,
                        None,
                        None,
                        None,
                        None,
                        None,
                        n_l2_output=2,
                        filter_shape_pooling=2,
                        step_shape_pooling=2)
        assert_array_equal(pcanet.histogram(images), expected)

        images = xp.array([[[1, 0, 1], [2, 0, 0], [1, 3, 3]],
                           [[2, 0, 0], [1, 1, 1], [3, 0, 1]]])
        expected = xp.array([[2, 1, 1, 0, 3, 1, 0, 0, 1, 1, 1, 1, 2, 0, 0, 2],
                             [1, 2, 1, 0, 2, 2, 0, 0, 1, 2, 0, 1, 1, 3, 0, 0]])
        pcanet = PCANet(None,
                        None,
                        None,
                        None,
                        None,
                        None,
                        n_l2_output=2,
                        filter_shape_pooling=2,
                        step_shape_pooling=1)
        assert_array_equal(pcanet.histogram(images), expected)
Esempio n. 2
0
    def test_histogram(self):
        image = np.array([[0, 1, 1, 3], [3, 1, 2, 2], [2, 0, 1, 2],
                          [2, 0, 1, 2], [1, 3, 0, 1], [2, 2, 2, 3]])
        expected = np.array([2, 2, 1, 1, 0, 2, 3, 1, 1, 1, 3, 1, 1, 2, 2, 1])

        pcanet = PCANet(None,
                        None,
                        None,
                        None,
                        None,
                        None,
                        n_l2_output=2,
                        block_shape=(3, 2))
        # assume that n_l1_output = 2
        assert_array_equal(pcanet.histogram(image), expected)