当前位置: 首页>>代码示例>>Python>>正文


Python argparse.ArgumentDefaultsHelpFormatter方法代码示例

本文整理汇总了Python中argparse.ArgumentDefaultsHelpFormatter方法的典型用法代码示例。如果您正苦于以下问题:Python argparse.ArgumentDefaultsHelpFormatter方法的具体用法?Python argparse.ArgumentDefaultsHelpFormatter怎么用?Python argparse.ArgumentDefaultsHelpFormatter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在argparse的用法示例。


在下文中一共展示了argparse.ArgumentDefaultsHelpFormatter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: parse_args

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import ArgumentDefaultsHelpFormatter [as 别名]
def parse_args():
    """Parse arguments."""
    parser = argparse.ArgumentParser(
        formatter_class=argparse.ArgumentDefaultsHelpFormatter,
        description='Diagnose script for checking the current system.')
    choices = ['python', 'pip', 'mxnet', 'os', 'hardware', 'network']
    for choice in choices:
        parser.add_argument('--' + choice, default=1, type=int,
                            help='Diagnose {}.'.format(choice))
    parser.add_argument('--region', default='', type=str,
                        help="Additional sites in which region(s) to test. \
                        Specify 'cn' for example to test mirror sites in China.")
    parser.add_argument('--timeout', default=10, type=int,
                        help="Connection test timeout threshold, 0 to disable.")
    args = parser.parse_args()
    return args 
开发者ID:awslabs,项目名称:dynamic-training-with-apache-mxnet-on-aws,代码行数:18,代码来源:diagnose.py

示例2: main

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import ArgumentDefaultsHelpFormatter [as 别名]
def main():
    """
    Calibrate the live camera and optionally do a live display of the results
    """
    parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument("config", type=Path, help="camera config path")
    parser.add_argument("--height", type=int, default=4)
    parser.add_argument("--width", type=int, default=10)
    parser.add_argument("--count", type=int, default=10)
    parser.add_argument("--view", action="store_true")
    args = parser.parse_args()

    config = {"camera": derp.util.load_config(args.config)}
    camera = Camera(config)
    pattern_shape = (args.height, args.width)

    camera_matrix, distortion_coefficients = live_calibrate(camera, pattern_shape, args.count)
    print(camera_matrix)
    print(distortion_coefficients)
    if args.view:
        live_undistort(camera, camera_matrix, distortion_coefficients)
    cv2.destroyAllWindows() 
开发者ID:notkarol,项目名称:derplearning,代码行数:24,代码来源:calibrate_camera.py

示例3: add_parser

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import ArgumentDefaultsHelpFormatter [as 别名]
def add_parser(subparser):
    parser = subparser.add_parser(
        "predict",
        help="predicts probability masks for slippy map tiles",
        formatter_class=argparse.ArgumentDefaultsHelpFormatter,
    )

    parser.add_argument("--batch_size", type=int, default=1, help="images per batch")
    parser.add_argument("--checkpoint", type=str, required=True, help="model checkpoint to load")
    parser.add_argument("--overlap", type=int, default=32, help="tile pixel overlap to predict on")
    parser.add_argument("--tile_size", type=int, required=True, help="tile size for slippy map tiles")
    parser.add_argument("--workers", type=int, default=0, help="number of workers pre-processing images")
    parser.add_argument("tiles", type=str, help="directory to read slippy map image tiles from")
    parser.add_argument("probs", type=str, help="directory to save slippy map probability masks to")
    parser.add_argument("--model", type=str, required=True, help="path to model configuration file")
    parser.add_argument("--dataset", type=str, required=True, help="path to dataset configuration file")

    parser.set_defaults(func=main) 
开发者ID:mapbox,项目名称:robosat,代码行数:20,代码来源:predict.py

示例4: parse_arguments

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import ArgumentDefaultsHelpFormatter [as 别名]
def parse_arguments():
    parser = argparse.ArgumentParser(
        description="Performs initial configuration of iDRACs.",
        formatter_class=argparse.ArgumentDefaultsHelpFormatter)

    ArgHelper.add_instack_arg(parser)
    ArgHelper.add_model_properties_arg(parser)

    LoggingHelper.add_argument(parser)

    parser.add_argument("-j",
                        "--json_config",
                        default=None,
                        help="""JSON that specifies the PXE NIC FQDD and the "
                            "new password for each overcloud node""")

    return parser.parse_args() 
开发者ID:dsp-jetpack,项目名称:JetPack,代码行数:19,代码来源:config_idracs.py

示例5: define_and_process_args

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import ArgumentDefaultsHelpFormatter [as 别名]
def define_and_process_args():
    """ Define and process command-line arguments.

    Returns:
        A Namespace with arguments as attributes.
    """

    description = main.__doc__
    formatter_class = argparse.ArgumentDefaultsHelpFormatter
    parser = argparse.ArgumentParser(description=description,
                                     formatter_class=formatter_class)

    parser.add_argument('--data_dir', default='~/Data/JIGSAWS/Suturing',
                        help='Data directory.')
    parser.add_argument('--data_filename', default='standardized_data.pkl',
                        help='''The name of the standardized-data pkl file that
                                we'll create inside data_dir.''')

    args = parser.parse_args()
    args.data_dir = os.path.expanduser(args.data_dir)
    return args 
开发者ID:rdipietro,项目名称:miccai-2016-surgical-activity-rec,代码行数:23,代码来源:standardize_jigsaws.py

示例6: check_args

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import ArgumentDefaultsHelpFormatter [as 别名]
def check_args():
    global params

    parser = argparse.ArgumentParser(
        description='OVS test', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument('--debug', dest='debug',
                        help='Enable debugging', default=False, action='store_true')
    parser.add_argument('--src_port_id', dest='src_port_id',
                        help='OVS src port id (required)', type=str, required=True)
    parser.add_argument('--dst_port_id', dest='dst_port_id',
                        help='OVS dst port id (required)', type=str, required=True)
    parser.add_argument(
        '--tag', dest='tag', help='VLAN tag of port (required)', type=str, required=True)
    parser.add_argument('--ovs_bridge', dest='ovs_bridge',
                        help='OVS bridge to be tested (required)', type=str, required=True)
    args = parser.parse_args()

    settings['debug'] = args.debug
    params['src_port_id'] = args.src_port_id
    params['dst_port_id'] = args.dst_port_id
    params['tag'] = args.tag
    params['ovs_bridge'] = args.ovs_bridge 
开发者ID:CiscoSystems,项目名称:don,代码行数:24,代码来源:ovs.py

示例7: prepare_args

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import ArgumentDefaultsHelpFormatter [as 别名]
def prepare_args():
    # parse args
    parser = argparse.ArgumentParser(description="train cifar10",
                                     formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    fit.add_fit_args(parser)
    data.add_data_args(parser)
    data.add_data_aug_args(parser)
    # uncomment to set standard cifar augmentations
    # set_cifar_aug(parser)
    parser.set_defaults(
        # network
        network        = 'resnet',
        num_layers     = 110,
        # data
        data_train     = train_fname,
        data_val       = val_fname,
        num_classes    = 10,
        num_examples  = 50000,
        image_shape    = '3,28,28',
        pad_size       = 4,
        # train
        batch_size     = 128,
        num_epochs     = 300,
        lr             = .05,
        lr_step_epochs = '200,250',
    )
    return parser.parse_args(), fit, data 
开发者ID:awslabs,项目名称:dynamic-training-with-apache-mxnet-on-aws,代码行数:29,代码来源:train_cifar10.py

示例8: parse_args

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import ArgumentDefaultsHelpFormatter [as 别名]
def parse_args():
    parser = argparse.ArgumentParser(description="Parse args for lstm_sort example",
                                     formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument('--start-range', type=int, default=100,
                        help='starting number of the range')
    parser.add_argument('--end-range', type=int, default=1000,
                        help='Ending number of the range')
    parser.add_argument('--cpu', action='store_true',
                        help='To use CPU for training')
    return parser.parse_args() 
开发者ID:awslabs,项目名称:dynamic-training-with-apache-mxnet-on-aws,代码行数:12,代码来源:lstm_sort.py

示例9: parse_args

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import ArgumentDefaultsHelpFormatter [as 别名]
def parse_args():
    parser = argparse.ArgumentParser(description='Demonstrate a Faster R-CNN network',
                                     formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument('--network', type=str, default='vgg16', help='base network')
    parser.add_argument('--params', type=str, default='', help='path to trained model')
    parser.add_argument('--dataset', type=str, default='voc', help='training dataset')
    parser.add_argument('--image', type=str, default='', help='path to test image')
    parser.add_argument('--gpu', type=str, default='', help='gpu device eg. 0')
    parser.add_argument('--vis', action='store_true', help='display results')
    parser.add_argument('--vis-thresh', type=float, default=0.7, help='threshold display boxes')
    # faster rcnn params
    parser.add_argument('--img-short-side', type=int, default=600)
    parser.add_argument('--img-long-side', type=int, default=1000)
    parser.add_argument('--img-pixel-means', type=str, default='(0.0, 0.0, 0.0)')
    parser.add_argument('--img-pixel-stds', type=str, default='(1.0, 1.0, 1.0)')
    parser.add_argument('--rpn-feat-stride', type=int, default=16)
    parser.add_argument('--rpn-anchor-scales', type=str, default='(8, 16, 32)')
    parser.add_argument('--rpn-anchor-ratios', type=str, default='(0.5, 1, 2)')
    parser.add_argument('--rpn-pre-nms-topk', type=int, default=6000)
    parser.add_argument('--rpn-post-nms-topk', type=int, default=300)
    parser.add_argument('--rpn-nms-thresh', type=float, default=0.7)
    parser.add_argument('--rpn-min-size', type=int, default=16)
    parser.add_argument('--rcnn-num-classes', type=int, default=21)
    parser.add_argument('--rcnn-feat-stride', type=int, default=16)
    parser.add_argument('--rcnn-pooled-size', type=str, default='(14, 14)')
    parser.add_argument('--rcnn-batch-size', type=int, default=1)
    parser.add_argument('--rcnn-bbox-stds', type=str, default='(0.1, 0.1, 0.2, 0.2)')
    parser.add_argument('--rcnn-nms-thresh', type=float, default=0.3)
    parser.add_argument('--rcnn-conf-thresh', type=float, default=1e-3)
    args = parser.parse_args()
    args.img_pixel_means = ast.literal_eval(args.img_pixel_means)
    args.img_pixel_stds = ast.literal_eval(args.img_pixel_stds)
    args.rpn_anchor_scales = ast.literal_eval(args.rpn_anchor_scales)
    args.rpn_anchor_ratios = ast.literal_eval(args.rpn_anchor_ratios)
    args.rcnn_pooled_size = ast.literal_eval(args.rcnn_pooled_size)
    args.rcnn_bbox_stds = ast.literal_eval(args.rcnn_bbox_stds)
    return args 
开发者ID:awslabs,项目名称:dynamic-training-with-apache-mxnet-on-aws,代码行数:39,代码来源:demo.py

示例10: parse_args

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import ArgumentDefaultsHelpFormatter [as 别名]
def parse_args():
    parser = argparse.ArgumentParser(description='Test a Faster R-CNN network',
                                     formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument('--network', type=str, default='vgg16', help='base network')
    parser.add_argument('--params', type=str, default='', help='path to trained model')
    parser.add_argument('--dataset', type=str, default='voc', help='training dataset')
    parser.add_argument('--imageset', type=str, default='', help='imageset splits')
    parser.add_argument('--gpu', type=int, default=0, help='gpu device eg. 0')
    # faster rcnn params
    parser.add_argument('--img-short-side', type=int, default=600)
    parser.add_argument('--img-long-side', type=int, default=1000)
    parser.add_argument('--img-pixel-means', type=str, default='(0.0, 0.0, 0.0)')
    parser.add_argument('--img-pixel-stds', type=str, default='(1.0, 1.0, 1.0)')
    parser.add_argument('--rpn-feat-stride', type=int, default=16)
    parser.add_argument('--rpn-anchor-scales', type=str, default='(8, 16, 32)')
    parser.add_argument('--rpn-anchor-ratios', type=str, default='(0.5, 1, 2)')
    parser.add_argument('--rpn-pre-nms-topk', type=int, default=6000)
    parser.add_argument('--rpn-post-nms-topk', type=int, default=300)
    parser.add_argument('--rpn-nms-thresh', type=float, default=0.7)
    parser.add_argument('--rpn-min-size', type=int, default=16)
    parser.add_argument('--rcnn-num-classes', type=int, default=21)
    parser.add_argument('--rcnn-feat-stride', type=int, default=16)
    parser.add_argument('--rcnn-pooled-size', type=str, default='(14, 14)')
    parser.add_argument('--rcnn-batch-size', type=int, default=1)
    parser.add_argument('--rcnn-bbox-stds', type=str, default='(0.1, 0.1, 0.2, 0.2)')
    parser.add_argument('--rcnn-nms-thresh', type=float, default=0.3)
    parser.add_argument('--rcnn-conf-thresh', type=float, default=1e-3)
    args = parser.parse_args()
    args.img_pixel_means = ast.literal_eval(args.img_pixel_means)
    args.img_pixel_stds = ast.literal_eval(args.img_pixel_stds)
    args.rpn_anchor_scales = ast.literal_eval(args.rpn_anchor_scales)
    args.rpn_anchor_ratios = ast.literal_eval(args.rpn_anchor_ratios)
    args.rcnn_pooled_size = ast.literal_eval(args.rcnn_pooled_size)
    args.rcnn_bbox_stds = ast.literal_eval(args.rcnn_bbox_stds)
    return args 
开发者ID:awslabs,项目名称:dynamic-training-with-apache-mxnet-on-aws,代码行数:37,代码来源:test.py

示例11: main

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import ArgumentDefaultsHelpFormatter [as 别名]
def main():
  parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
  parser.add_argument('--env', help='environment ID (0==sine, 1==stand, 2=reset, 3=overheat)',type=int,  default=0)
  args = parser.parse_args()
  print("--env=" + str(args.env))
    
  if (args.env == 0):
    SinePolicyExample()
  if (args.env == 1):
    SineStandExample()
  if (args.env == 2):
    ResetPoseExample()
  if (args.env == 3):
    MotorOverheatExample() 
开发者ID:utra-robosoccer,项目名称:soccer-matlab,代码行数:16,代码来源:minitaur_gym_env_example.py

示例12: main

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import ArgumentDefaultsHelpFormatter [as 别名]
def main():
    import argparse
    parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument('--env', help='environment ID', default='AntBulletEnv-v0')
    parser.add_argument('--seed', help='RNG seed', type=int, default=0)
    parser.add_argument('--render', help='OpenGL Visualizer', type=int, default=0)
    parser.add_argument('--rgb',help='rgb_array gym rendering',type=int, default=0)
    parser.add_argument('--resetbenchmark',help='Repeat reset to show reset performance',type=int, default=0)
    parser.add_argument('--steps', help='Number of steps', type=int, default=1)
    
    args = parser.parse_args()
    test(args) 
开发者ID:utra-robosoccer,项目名称:soccer-matlab,代码行数:14,代码来源:testEnv.py

示例13: main

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import ArgumentDefaultsHelpFormatter [as 别名]
def main():
    parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument('--env', help='environment ID (0==sine, 1==stand, 2=reset, 3=overheat)',type=int,  default=0)
    args = parser.parse_args()
    print("--env=" + str(args.env))
      
    if (args.env == 0):
      SinePolicyExample()
    if (args.env == 1):
      SineStandExample()
    if (args.env == 2):
      ResetPoseExample()
    if (args.env == 3):
      MotorOverheatExample() 
开发者ID:utra-robosoccer,项目名称:soccer-matlab,代码行数:16,代码来源:minitaur_gym_env_example.py

示例14: main

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import ArgumentDefaultsHelpFormatter [as 别名]
def main():
    parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument('--env', help='environment ID (0==reset)',type=int,  default=0)
    args = parser.parse_args()
    print("--env=" + str(args.env))
      
    if (args.env == 0):
      ResetPoseExample(steps = 1000) 
开发者ID:utra-robosoccer,项目名称:soccer-matlab,代码行数:10,代码来源:test_pybullet_sim_gym_env.py

示例15: main

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import ArgumentDefaultsHelpFormatter [as 别名]
def main():
    parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument('--env', help='environment ID', default='BreakoutNoFrameskip-v4')
    parser.add_argument('--seed', help='RNG seed', type=int, default=0)
    parser.add_argument('--prioritized', type=int, default=1)
    parser.add_argument('--dueling', type=int, default=1)
    parser.add_argument('--num-timesteps', type=int, default=int(10e6))
    args = parser.parse_args()
    logger.configure()
    set_global_seeds(args.seed)
    env = make_atari(args.env)
    env = bench.Monitor(env, logger.get_dir())
    env = deepq.wrap_atari_dqn(env)
    model = deepq.models.cnn_to_mlp(
        convs=[(32, 8, 4), (64, 4, 2), (64, 3, 1)],
        hiddens=[256],
        dueling=bool(args.dueling),
    )
    act = deepq.learn(
        env,
        q_func=model,
        lr=1e-4,
        max_timesteps=args.num_timesteps,
        buffer_size=10000,
        exploration_fraction=0.1,
        exploration_final_eps=0.01,
        train_freq=4,
        learning_starts=10000,
        target_network_update_freq=1000,
        gamma=0.99,
        prioritized_replay=bool(args.prioritized)
    )
    # act.save("pong_model.pkl") XXX
    env.close() 
开发者ID:Hwhitetooth,项目名称:lirpg,代码行数:36,代码来源:run_atari.py


注:本文中的argparse.ArgumentDefaultsHelpFormatter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。