Argparse package in Python--for parsing command-line arguments

Source: Internet
Author: User
Tags random seed

Python comes with a argparse package that is commonly used to parse command-line parameters using the method Example:
ImportArgparse Parser= Argparse. Argumentparser ()#instantiate the Argumentparser class in the Argparse package#add argument to parser and its specific parameters are set in the official website manualParser.add_argument ('--seed', Type=int, default=42, help='Random seed.') parser.add_argument ('--epochs', Type=int, default=200, help='Number of epochs to train.') parser.add_argument ('--LR', Type=float, default=0.01, help='Initial learning rate.') parser.add_argument ('--weight_decay', Type=float, Default=5e-4, help='Weight decay (L2 loss on parameters).') parser.add_argument ('--hidden', Type=int, default=16, help='Number of hidden units.') parser.add_argument ('--dropout', Type=float, default=0.5, help='Dropout rate (1-keep probability).') args= Parser.parse_args ()#syntax analysis with parser using the command line

Reference:

Https://docs.python.org/3/library/argparse.html#the-parse-args-method

Argparse package in Python--for parsing command-line arguments

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.