#NEWLINE# def distorted_inputs( batch_size = FLAGS . batch_size , num_epochs = FLAGS . num_epochs ) : #NEWLINE# #INDENT# 'Construct distorted input for CIFAR training using the Reader ops.\n\n  Raises:\n    ValueError: if no data_dir\n\n  Returns:\n    images: Images. 4D tensor of [batch_size, IMAGE_SIZE, IMAGE_SIZE, 3] size.\n    labels: Labels. 1D tensor of [batch_size] size.\n  ' #NEWLINE# if ( not num_epochs ) : #NEWLINE# #INDENT# num_epochs = None #NEWLINE# #UNINDENT# filename = os . path . join ( FLAGS . train_dir , TRAIN_FILE ) #NEWLINE# with tf . name_scope ( 'input' ) : #NEWLINE# #INDENT# filename_queue = tf . train . string_input_producer ( [ filename ] , num_epochs = num_epochs , name = 'string_DISTORTED_input_producer' ) #NEWLINE# ( image , label ) = read_and_decode ( filename_queue ) #NEWLINE# image = tf . reshape ( image , IMAGE_SHAPE ) #NEWLINE# height = IMAGE_SIZE #NEWLINE# width = IMAGE_SIZE #NEWLINE# distorted_image = tf . image . random_crop ( image , [ height , width ] ) #NEWLINE# distorted_image = tf . image . random_flip_left_right ( distorted_image ) #NEWLINE# distorted_image = tf . image . random_brightness ( image , max_delta = 63 ) #NEWLINE# distorted_image = tf . image . random_contrast ( distorted_image , lower = 0.2 , upper = 1.8 ) #NEWLINE# float_image = tf . image . per_image_whitening ( distorted_image ) #NEWLINE# image = tf . reshape ( float_image , [ my_cifar . n_input ] ) #NEWLINE# min_fraction_of_examples_in_queue = 0.4 #NEWLINE# min_queue_examples = int ( ( NUM_EXAMPLES_PER_EPOCH_FOR_TRAIN * min_fraction_of_examples_in_queue ) ) #NEWLINE# ( images , sparse_labels ) = tf . train . shuffle_batch ( [ image , label ] , batch_size = batch_size , num_threads = 5 , capacity = ( min_queue_examples + ( 3 * batch_size ) ) , enqueue_many = False , min_after_dequeue = min_queue_examples , name = 'batching_shuffling_distortion' ) #NEWLINE# #UNINDENT# return ( images , sparse_labels )