def testDynamicTileAndConcat(self):
    # image = (1 X 4 X 4 X 1)
    image = [[1, 2, 3, 4],
             [2, 4, 5, 6],
             [7, 8, 9, 10],
             [7, 9, 10, 1]]
    image_t = tf.expand_dims(tf.expand_dims(image, axis=0), axis=-1)
    image_t = tf.cast(image_t, dtype=tf.float32)

    # latent = (1 X 2)
    latent = np.array([[90, 100]])
    latent_t = tf.cast(tf.convert_to_tensor(latent), dtype=tf.float32)

    tiled = common_video.tile_and_concat(
        image_t, latent_t)
    tiled_np, image_np = self.evaluate([tiled, image_t])
    tiled_latent = tiled_np[0, :, :, -1]
    self.assertAllEqual(tiled_np.shape, (1, 4, 4, 2))

    self.assertAllEqual(tiled_np[:, :, :, :1], image_np)
    self.assertAllEqual(
        tiled_latent,
        [[90, 90, 90, 90],
         [100, 100, 100, 100],
         [90, 90, 90, 90],
         [100, 100, 100, 100]])
Esempio n. 2
0
  def testDynamicTileAndConcat(self):
    # image = (1 X 4 X 4 X 1)
    image = [[1, 2, 3, 4],
             [2, 4, 5, 6],
             [7, 8, 9, 10],
             [7, 9, 10, 1]]
    image_t = tf.expand_dims(tf.expand_dims(image, axis=0), axis=-1)
    image_t = tf.cast(image_t, dtype=tf.float32)

    # latent = (1 X 2)
    latent = np.array([[90, 100]])
    latent_t = tf.cast(tf.convert_to_tensor(latent), dtype=tf.float32)

    tiled = common_video.tile_and_concat(
        image_t, latent_t)
    tiled_np, image_np = self.evaluate([tiled, image_t])
    tiled_latent = tiled_np[0, :, :, -1]
    self.assertAllEqual(tiled_np.shape, (1, 4, 4, 2))

    self.assertAllEqual(tiled_np[:, :, :, :1], image_np)
    self.assertAllEqual(
        tiled_latent,
        [[90, 90, 90, 90],
         [100, 100, 100, 100],
         [90, 90, 90, 90],
         [100, 100, 100, 100]])