I'm reading the tensorflow tutorial file fully_connected_feed.py
which contains the following code. I do not understand what those mean. Why do we need that? It seems that it's just defining some global variables. Why not just define those 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.')
This is google's way for parsing arguments from the commandline. Have a look at python-gflags. As far as I'm aware, google is the primary user of this commandline parsing library. The rest of the world uses argparse
these days.
But basically, the "tl;dr;" is that you're right -- They are setting up global data. However, it's global data that can be fiddled with via the commandline.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With