def read_and_decode(filename, is_train=None):
filename_queue = tf.train.string_input_producer([filename])<EOL>reader = tf.TFRecordReader()<EOL>_, serialized_example = reader.read(filename_queue)<EOL>features = tf.parse_single_example(<EOL>serialized_example, features={<EOL>'<STR_LIT:label>': tf.FixedLenFeature([], tf.int64),<EOL>'<STR_LIT>': tf.FixedLenFeature([], tf.string),<EOL>}<EOL>)<EOL>img = tf.decode_raw(features['<STR_LIT>'], tf.float32)<EOL>img = tf.reshape(img, [<NUM_LIT:32>, <NUM_LIT:32>, <NUM_LIT:3>])<EOL>if is_train ==True:<EOL><INDENT>img = tf.random_crop(img, [<NUM_LIT>, <NUM_LIT>, <NUM_LIT:3>])<EOL>img = tf.image.random_flip_left_right(img)<EOL>img = tf.image.random_brightness(img, max_delta=<NUM_LIT>)<EOL>img = tf.image.random_contrast(img, lower=<NUM_LIT>, upper=<NUM_LIT>)<EOL>img = tf.image.per_image_standardization(img)<EOL><DEDENT>elif is_train == False:<EOL><INDENT>img = tf.image.resize_image_with_crop_or_pad(img, <NUM_LIT>, <NUM_LIT>)<EOL>img = tf.image.per_image_standardization(img)<EOL><DEDENT>elif is_train == None:<EOL><INDENT>img = img<EOL><DEDENT>label = tf.cast(features['<STR_LIT:label>'], tf.int32)<EOL>return img, label<EOL>
Return tensor to read from TFRecord.