python - How to use "FLAGS" (command line switches) in TensorFlow? -
i trying set custom batch size in application.
if put following code app
tf.app.flags.define_integer('batch_size', 128, """number of images process in batch.""")
it says following error
argparse.argumenterror: argument --batch_size: conflicting option string(s): --batch_size
and if remove statement, swears:
usage: <myscript> [-h] [--batch_size batch_size] [--data_dir data_dir] [--checkpoint_dir checkpoint_dir]
at line flags.batch_size
used.
myscript
name of script , didn't write message anywhere , don't expect these command line switches @ all. looks tf
uses python switch parsing library , expecting these switches somehow. how avoid , expect custom switches?
how hardcode custom batch_size?
update
my command line follows:
myscript image1.png image2.png image3.png
pngs images cifar database wish recognize command line. command line wish be, don't wish contain options listed in "usage" output.
from update, sounds don't want use flags
module @ all. if @ program cifar10_train.py
, you'll see following near bottom of script:
def main(argv=none): # pylint: disable=unused-argument # ... if __name__ == '__main__': tf.app.run()
the tf.app.run()
invocation bit of boilerplate ensures flags parsed, , invokes main()
function in same module. notice main()
has argv
argument. filled remaining arguments program: in example, list ["image1.png", "image2.png", "image3.png"]
. therefore can write main()
function like:
def main(argv=none): if argv: filename in argv: run_inference_on_file(filename)
Comments
Post a Comment