예제 #1
0
 def test_upsample_value(self):
   image = tf.random.normal([10, 32, 32, 3])
   big_image = generator.usample(image)
   expected_image = tf.compat.v1.image.resize_nearest_neighbor(
       image, [32 * 2, 32 * 2])
   with self.cached_session() as sess:
     big_image_np, expected_image_np = sess.run([big_image, expected_image])
   self.assertAllEqual(big_image_np, expected_image_np)
예제 #2
0
 def test_usample_shapes_value_placeholder(self):
     """Tests usample with partially shaped inputs."""
     if tf.executing_eagerly():
         # tf.placeholder() is not compatible with eager execution.
         return
     image = tf.placeholder(tf.float32, shape=[None, 32, 32, 3])
     big_image = generator.usample(image)
     self.assertEqual([None, 64, 64, 3], big_image.shape.as_list())
     expected_image = tf.image.resize_nearest_neighbor(
         image, [32 * 2, 32 * 2])
     with self.cached_session() as sess:
         big_image_np, expected_image_np = sess.run(
             [big_image, expected_image],
             {image: np.random.normal(size=[10, 32, 32, 3])})
     self.assertAllEqual(big_image_np, expected_image_np)
예제 #3
0
 def test_usample_shapes(self):
     """Tests that upsampling has the desired effect on shape."""
     image = tf.random.normal([10, 32, 32, 3])
     big_image = generator.usample(image)
     self.assertEqual([10, 64, 64, 3], big_image.shape.as_list())