Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the purpose of "FLAGS" in tensorflow

I am studying the mnist example in tensorflow.

I am confused with the module FLAGS

# Basic model parameters as external flags.
FLAGS = None

In the "run_training" funcition :

def run_training():
"""Train MNIST for a number of steps."""
# Tell TensorFlow that the model will be built into the default Graph.
with tf.Graph().as_default():
# Input images and labels.
images, labels = inputs(train=True, batch_size=FLAGS.batch_size,
                        num_epochs=FLAGS.num_epochs)

What's the purpose of using "FLAGS.batch_size" and "FLAGS.num_epochs" here? Can I just replace it with a constant number like 128?

I found a similar answer in this site but I still can't understand.

like image 847
JimReno Avatar asked Dec 06 '22 14:12

JimReno


1 Answers

The flags are generally used to parse command line arguments and hold input parameters. You could replace them with constant numbers, but it is good practice to organise your input parameters with the help of flags.

like image 139
Agost Biro Avatar answered Dec 10 '22 17:12

Agost Biro