Skip to content

Commit 0785f0c

Browse files
authored
Revert "Flags"
1 parent ad5c1fb commit 0785f0c

File tree

4 files changed

+41
-58
lines changed

4 files changed

+41
-58
lines changed

tutorials/image/cifar10/cifar10.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
from __future__ import division
3636
from __future__ import print_function
3737

38-
import argparse
3938
import os
4039
import re
4140
import sys
@@ -46,19 +45,15 @@
4645

4746
import cifar10_input
4847

49-
parser = argparse.ArgumentParser()
48+
FLAGS = tf.app.flags.FLAGS
5049

5150
# Basic model parameters.
52-
parser.add_argument('--batch_size', type=int, default=128,
53-
help='Number of images to process in a batch.')
54-
55-
parser.add_argument('--data_dir', type=str, default='/tmp/cifar10_data',
56-
help='Path to the CIFAR-10 data directory.')
57-
58-
parser.add_argument('--use_fp16', type=bool, default=False,
59-
help='Train the model using fp16.')
60-
61-
FLAGS = parser.parse_args()
51+
tf.app.flags.DEFINE_integer('batch_size', 128,
52+
"""Number of images to process in a batch.""")
53+
tf.app.flags.DEFINE_string('data_dir', '/tmp/cifar10_data',
54+
"""Path to the CIFAR-10 data directory.""")
55+
tf.app.flags.DEFINE_boolean('use_fp16', False,
56+
"""Train the model using fp16.""")
6257

6358
# Global constants describing the CIFAR-10 data set.
6459
IMAGE_SIZE = cifar10_input.IMAGE_SIZE

tutorials/image/cifar10/cifar10_eval.py

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,25 +43,20 @@
4343

4444
import cifar10
4545

46-
parser = cifar10.parser
47-
48-
parser.add_argument('--eval_dir', type=str, default='/tmp/cifar10_eval',
49-
help='Directory where to write event logs.')
50-
51-
parser.add_argument('--eval_data', type=str, default='test',
52-
help='Either `test` or `train_eval`.')
53-
54-
parser.add_argument('--checkpoint_dir', type=str, default='/tmp/cifar10_train',
55-
help='Directory where to read model checkpoints.')
56-
57-
parser.add_argument('--eval_interval_secs', type=int, default=60*5,
58-
help='How often to run the eval.')
59-
60-
parser.add_argument('--num_examples', type=int, default=10000,
61-
help='Number of examples to run.')
62-
63-
parser.add_argument('--run_once', type=bool, default=False,
64-
help='Whether to run eval only once.')
46+
FLAGS = tf.app.flags.FLAGS
47+
48+
tf.app.flags.DEFINE_string('eval_dir', '/tmp/cifar10_eval',
49+
"""Directory where to write event logs.""")
50+
tf.app.flags.DEFINE_string('eval_data', 'test',
51+
"""Either 'test' or 'train_eval'.""")
52+
tf.app.flags.DEFINE_string('checkpoint_dir', '/tmp/cifar10_train',
53+
"""Directory where to read model checkpoints.""")
54+
tf.app.flags.DEFINE_integer('eval_interval_secs', 60 * 5,
55+
"""How often to run the eval.""")
56+
tf.app.flags.DEFINE_integer('num_examples', 10000,
57+
"""Number of examples to run.""")
58+
tf.app.flags.DEFINE_boolean('run_once', False,
59+
"""Whether to run eval only once.""")
6560

6661

6762
def eval_once(saver, summary_writer, top_k_op, summary_op):
@@ -159,5 +154,4 @@ def main(argv=None): # pylint: disable=unused-argument
159154

160155

161156
if __name__ == '__main__':
162-
FLAGS = parser.parse_args()
163157
tf.app.run()

tutorials/image/cifar10/cifar10_multi_gpu_train.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,17 @@
4949
import tensorflow as tf
5050
import cifar10
5151

52-
parser = cifar10.parser
52+
FLAGS = tf.app.flags.FLAGS
5353

54-
parser.add_argument('--train_dir', type=str, default='/tmp/cifar10_train',
55-
help='Directory where to write event logs and checkpoint.')
56-
57-
parser.add_argument('--max_steps', type=int, default=1000000,
58-
help='Number of batches to run.')
59-
60-
parser.add_argument('--num_gpus', type=int, default=1,
61-
help='How many GPUs to use.')
62-
63-
parser.add_argument('--log_device_placement', type=bool, default=False,
64-
help='Whether to log device placement.')
54+
tf.app.flags.DEFINE_string('train_dir', '/tmp/cifar10_train',
55+
"""Directory where to write event logs """
56+
"""and checkpoint.""")
57+
tf.app.flags.DEFINE_integer('max_steps', 1000000,
58+
"""Number of batches to run.""")
59+
tf.app.flags.DEFINE_integer('num_gpus', 1,
60+
"""How many GPUs to use.""")
61+
tf.app.flags.DEFINE_boolean('log_device_placement', False,
62+
"""Whether to log device placement.""")
6563

6664

6765
def tower_loss(scope, images, labels):
@@ -276,5 +274,4 @@ def main(argv=None): # pylint: disable=unused-argument
276274

277275

278276
if __name__ == '__main__':
279-
FLAGS = parser.parse_args()
280277
tf.app.run()

tutorials/image/cifar10/cifar10_train.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,17 @@
4343

4444
import cifar10
4545

46-
parser = cifar10.parser
46+
FLAGS = tf.app.flags.FLAGS
4747

48-
parser.add_argument('--train_dir', type=str, default='/tmp/cifar10_train',
49-
help='Directory where to write event logs and checkpoint.')
50-
51-
parser.add_argument('--max_steps', type=int, default=1000000,
52-
help='Number of batches to run.')
53-
54-
parser.add_argument('--log_device_placement', type=bool, default=False,
55-
help='Whether to log device placement.')
56-
57-
parser.add_argument('--log_frequency', type=int, default=10,
58-
help='How often to log results to the console.')
48+
tf.app.flags.DEFINE_string('train_dir', '/tmp/cifar10_train',
49+
"""Directory where to write event logs """
50+
"""and checkpoint.""")
51+
tf.app.flags.DEFINE_integer('max_steps', 1000000,
52+
"""Number of batches to run.""")
53+
tf.app.flags.DEFINE_boolean('log_device_placement', False,
54+
"""Whether to log device placement.""")
55+
tf.app.flags.DEFINE_integer('log_frequency', 10,
56+
"""How often to log results to the console.""")
5957

6058

6159
def train():
@@ -126,5 +124,4 @@ def main(argv=None): # pylint: disable=unused-argument
126124

127125

128126
if __name__ == '__main__':
129-
FLAGS = parser.parse_args()
130127
tf.app.run()

0 commit comments

Comments
 (0)