示例#1
0
 def test_prepare_video(self):
     # at each timestep the sum over all other dimensions of the video should stay the same
     V_before = np.random.random((4, 10, 3, 20, 20))
     V_after = _prepare_video(np.copy(V_before))
     V_before = np.swapaxes(V_before, 0, 1)
     V_before = np.reshape(V_before, newshape=(10, -1))
     V_after = np.reshape(V_after, newshape=(10, -1))
     np.testing.assert_array_almost_equal(np.sum(V_before, axis=1), np.sum(V_after, axis=1))
示例#2
0
 def test_numpy_vid_uint8(self):
     V_input = np.random.randint(0, 256, (16, 30, 3, 28, 28)).astype(np.uint8)
     V_after = _prepare_video(np.copy(V_input)) * 255
     total_frame = V_input.shape[1]
     V_input = np.swapaxes(V_input, 0, 1)
     for f in range(total_frame):
         x = np.reshape(V_input[f], newshape=(-1))
         y = np.reshape(V_after[f], newshape=(-1))
         np.testing.assert_array_almost_equal(np.sum(x), np.sum(y))
示例#3
0
 def test_prepare_video(self):
     # At each timeframe, the sum over all other
     # dimensions of the video should be the same.
     shapes = [(16, 30, 3, 28, 28), (36, 30, 3, 28, 28),
               (19, 29, 3, 23, 19), (3, 3, 3, 3, 3)]
     for s in shapes:
         V_input = np.random.random(s)
         V_after = _prepare_video(np.copy(V_input))
         total_frame = s[1]
         V_input = np.swapaxes(V_input, 0, 1)
         for f in range(total_frame):
             x = np.reshape(V_input[f], newshape=(-1))
             y = np.reshape(V_after[f], newshape=(-1))
             np.testing.assert_array_almost_equal(np.sum(x), np.sum(y))