// The first byte represent the coarse-label.
// Extract the second byte that"s the fine-label and convert it from uint8->int32.
result["label"] = tf.cast(
tf.slice(record_bytes, [1], [label_bytes - 1]), tf.int32)
// The remaining bytes after the label represent the image, which we reshape
// from [depth * height * width] to [depth, height, width].
depth_major = tf.reshape(
tf.slice(record_bytes, [label_bytes], [image_bytes]),
[result["depth"], result["height"], result["width"]])
// Convert from [depth, height, width] to [height, width, depth].
image = tf.cast(tf.transpose(depth_major, [1, 2, 0]), tf.float32)
// Convert from [0, 255] -> [0, 1]
image = tf.divide(image, 255.0)
After Change
// The first byte represent the coarse-label.
// Extract the second byte that"s the fine-label and convert it from uint8->int32.
result["label"] = tf.squeeze(
tf.cast(tf.slice(record_bytes, [1], [label_bytes - 1]), tf.int32))
// The remaining bytes after the label represent the image, which we reshape
// from [depth * height * width] to [depth, height, width].
depth_major = tf.reshape(
tf.slice(record_bytes, [label_bytes], [image_bytes]),
[result["depth"], result["height"], result["width"]])
// Convert from [depth, height, width] to [height, width, depth].
image = tf.cast(tf.transpose(depth_major, [1, 2, 0]), tf.float32)
// Convert from [0, 255] -> [0, 1]
image = tf.divide(image, 255.0)