Пример #1
0
    def test_get_topological_view(self):
        norb = SmallNORB('train')

        # Get a topological view as a single "(b, s, 0 1, c)" tensor.
        topo_tensor = norb.get_topological_view(single_tensor=True)
        shape = (norb.X.shape[0], 2) + SmallNORB.original_image_shape + (1, )
        expected_topo_tensor = norb.X.reshape(shape)
        assert numpy.all(topo_tensor == expected_topo_tensor)

        # Get a topological view as two "(b, 0, 1, c)" tensors
        topo_tensors = norb.get_topological_view(single_tensor=False)
        expected_topo_tensors = tuple(expected_topo_tensor[:, i, ...]
                                      for i in range(2))

        for topo_tensor, expected_topo_tensor in \
            safe_zip(topo_tensors, expected_topo_tensors):
            assert numpy.all(topo_tensor == expected_topo_tensor)
Пример #2
0
    def test_get_topological_view(self):
        norb = SmallNORB('train')

        # Get a topological view as a single "(b, s, 0 1, c)" tensor.
        topo_tensor = norb.get_topological_view(single_tensor=True)
        shape = (norb.X.shape[0], 2) + SmallNORB.original_image_shape + (1, )
        expected_topo_tensor = norb.X.reshape(shape)
        assert numpy.all(topo_tensor == expected_topo_tensor)

        # Get a topological view as two "(b, 0, 1, c)" tensors
        topo_tensors = norb.get_topological_view(single_tensor=False)
        expected_topo_tensors = tuple(expected_topo_tensor[:, i, ...]
                                      for i in range(2))

        for topo_tensor, expected_topo_tensor in \
            safe_zip(topo_tensors, expected_topo_tensors):
            assert numpy.all(topo_tensor == expected_topo_tensor)
Пример #3
0
    def test_get_topological_view(self):
        # This is just to lower the memory usage. Otherwise, the
        # buildbot use close to 10G of ram.
        norb = SmallNORB('train', stop=1000)

        # Get a topological view as a single "(b, s, 0 1, c)" tensor.
        topo_tensor = norb.get_topological_view(single_tensor=True)
        shape = (norb.X.shape[0], 2) + SmallNORB.original_image_shape + (1, )
        expected_topo_tensor = norb.X.reshape(shape)
        # We loop to lower the peak memory usage
        for i in range(topo_tensor.shape[0]):
            assert numpy.all(topo_tensor[i] == expected_topo_tensor[i])

        # Get a topological view as two "(b, 0, 1, c)" tensors
        topo_tensors = norb.get_topological_view(single_tensor=False)
        expected_topo_tensors = tuple(expected_topo_tensor[:, i, ...]
                                      for i in range(2))

        for topo_tensor, expected_topo_tensor in safe_zip(
                topo_tensors, expected_topo_tensors):
            assert numpy.all(topo_tensor == expected_topo_tensor)