示例#1
0
 def preprocess(x):
     """Cast to float, normalize, and concatenate images along last axis."""
     x = nest.map_structure(
         lambda image: tf.image.convert_image_dtype(image, tf.float32), x)
     x = nest.flatten(x)
     x = tf.concat(x, axis=-1)
     x = (tf.image.convert_image_dtype(x, tf.float32) - 0.5) * 2.0
     return x
示例#2
0
 def preprocess(x):
     """Cast to float, normalize, and concatenate images along last axis."""
     import tensorflow as tf
     x = nest.map_structure(
         lambda image: tf.image.convert_image_dtype(image, tf.float32), x)
     x = nest.flatten(x)
     x = tf.concat(x, axis=-1)
     # x = (tf.image.convert_image_dtype(x, tf.float32) - 0.5) * 2.0
     # TODO: Why is the image being converted to float32 twice? Once in the
     # nest and once down here?
     x = (high - low) * tf.image.convert_image_dtype(x, tf.float32) + low
     return x
示例#3
0
 def cast_and_concat(x):
     x = nest.map_structure(lambda element: tf.cast(element, tf.float32), x)
     x = nest.flatten(x)
     x = tf.concat(x, axis=-1)
     return x
示例#4
0
 def cast_and_concat(x):
     x = nest.map_structure(training_utils.cast_if_floating_dtype, x)
     x = nest.flatten(x)
     x = tf.concat(x, axis=-1)
     return x