5252###############################################################################
5353def get_filenames (is_training , data_dir ):
5454 """Returns a list of filenames."""
55- assert tf .io . gfile .exists (data_dir ), (
55+ assert tf .gfile .Exists (data_dir ), (
5656 'Run cifar10_download_and_extract.py first to download and extract the '
5757 'CIFAR-10 data.' )
5858
@@ -68,7 +68,7 @@ def get_filenames(is_training, data_dir):
6868def parse_record (raw_record , is_training , dtype ):
6969 """Parse CIFAR-10 image and label from a raw record."""
7070 # Convert bytes to a vector of uint8 that is record_bytes long.
71- record_vector = tf .io . decode_raw (raw_record , tf .uint8 )
71+ record_vector = tf .decode_raw (raw_record , tf .uint8 )
7272
7373 # The first byte represents the label, which we convert from uint8 to int32
7474 # and then to one-hot.
@@ -81,7 +81,7 @@ def parse_record(raw_record, is_training, dtype):
8181
8282 # Convert from [depth, height, width] to [height, width, depth], and cast as
8383 # float32.
84- image = tf .cast (tf .transpose (a = depth_major , perm = [1 , 2 , 0 ]), tf .float32 )
84+ image = tf .cast (tf .transpose (depth_major , [1 , 2 , 0 ]), tf .float32 )
8585
8686 image = preprocess_image (image , is_training )
8787 image = tf .cast (image , dtype )
@@ -97,7 +97,7 @@ def preprocess_image(image, is_training):
9797 image , HEIGHT + 8 , WIDTH + 8 )
9898
9999 # Randomly crop a [HEIGHT, WIDTH] section of the image.
100- image = tf .image . random_crop (image , [HEIGHT , WIDTH , NUM_CHANNELS ])
100+ image = tf .random_crop (image , [HEIGHT , WIDTH , NUM_CHANNELS ])
101101
102102 # Randomly flip the image horizontally.
103103 image = tf .image .random_flip_left_right (image )
@@ -253,9 +253,8 @@ def run_cifar(flags_obj):
253253 Dictionary of results. Including final accuracy.
254254 """
255255 if flags_obj .image_bytes_as_serving_input :
256- tf .compat .v1 .logging .fatal (
257- '--image_bytes_as_serving_input cannot be set to True for CIFAR. '
258- 'This flag is only applicable to ImageNet.' )
256+ tf .logging .fatal ('--image_bytes_as_serving_input cannot be set to True '
257+ 'for CIFAR. This flag is only applicable to ImageNet.' )
259258 return
260259
261260 input_function = (flags_obj .use_synthetic_data and
@@ -274,6 +273,6 @@ def main(_):
274273
275274
276275if __name__ == '__main__' :
277- tf .compat . v1 . logging .set_verbosity (tf . compat . v1 .logging .INFO )
276+ tf .logging .set_verbosity (tf .logging .INFO )
278277 define_cifar_flags ()
279278 absl_app .run (main )
0 commit comments