def _image_op_cifar10(filenames, relative_colors):
label_bytes = 1
height = 32
width = 32
depth = 3
image_bytes = height * width * depth
record_bytes = label_bytes + image_bytes
filename_queue = tf.train.string_input_producer(filenames, num_epochs=1)
reader = tf.FixedLengthRecordReader(record_bytes=record_bytes)
_, value = reader.read(filename_queue)
record_bytes = tf.decode_raw(value, tf.uint8)
depth_major = tf.reshape(tf.slice(record_bytes, [label_bytes], [image_bytes]), [depth, height, width])
image = tf.transpose(depth_major, [1, 2, 0])
image = tf.cast(image, tf.float32)
if relative_colors:
image = util.absolute_to_relative_colors(image)
return image
评论列表
文章目录