Why is FLAGS Necessary?_tensorflow

Source: Internet
Author: User

SOURCE Url:https://stackoverflow.com/questions/43437590/why-is-flags-necessary

Usually FLAGS are used to pass command line arguments into your program. e.g.

Import TensorFlow as tf
fs = Tf.app.flags
fs. Define_integer (' N_epochs ', +, ' number of epochs to train [] ')
FLAGS = fs. FLAGS

def Main (argv):
    print (FLAGS.N_EPOCHS)

if __name__ = = ' __main__ ':
    tf.app.run ()

If you run this snippet from the command line as Python snippet.py, it'll print

25

If you run Python snippet.py--n_epochs it'll print

50

You are could achieve the same thing with Python ' s package argparse.

In the example your posted the use of the ' FLAGS is admittedly a bit strange. Here it could being replaced by just directly defining the variables, unless the FLAGS variable are used else in the Code, which you don't showing here are.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.