What does tf.app.flags do? why do we need this?

I am reading the tasorflow fully_connected_feed.py instructions fully_connected_feed.py , which contains the following code. I do not understand what it means. Why do we need this? It looks like it just defines some global variables. Why not just define them directly? Any help is appreciated. thanks

 flags = tf.app.flags FLAGS = flags.FLAGS flags.DEFINE_float('learning_rate', 0.01, 'Initial learning rate.') flags.DEFINE_integer('max_steps', 2000, 'Number of steps to run trainer.') flags.DEFINE_integer('hidden1', 128, 'Number of units in hidden layer 1.') flags.DEFINE_integer('hidden2', 32, 'Number of units in hidden layer 2.') flags.DEFINE_integer('batch_size', 100, 'Batch size. ' 'Must divide evenly into the dataset sizes.') flags.DEFINE_string('train_dir', 'data', 'Directory to put the training data.') flags.DEFINE_boolean('fake_data', False, 'If true, uses fake data ' 'for unit testing.') 
+7
python deep-learning tensorflow
source share
1 answer

This is a google method for parsing arguments from the command line. Take a look at python-gflags . As far as I know, google is the main user of this command line parsing. The rest of the world uses argparse these days.

But basically, "tl; dr;" that you are right - they create global data. However, this is global data that can be used using the command line.

+10
source share

All Articles