关于下面示例中使用的batch_size参数,我有一个问题。
https://github.com/pytorch/examples/blob/master/imagenet/main.py#L150
parser.add_argument('-b', '--batch-size', default=256, type=int,
metavar='N',
# dest='batch_size' why this is not needed?
help='mini-batch size (default: 256), this is the total '
'batch size of all GPUs on the current node when '
'using Data Parallel or Distributed Data Parallel')
# missing code
args.batch_size = int(args.batch_size / ngpus_per_node)我的问题是,如果没有dest参数,如何从命令行解析和保存batch_size?
发布于 2019-02-22 01:33:55
来自https://docs.python.org/2/library/argparse.html#dest
ArgumentParser通过获取第一个长选项字符串并去掉初始的--字符串来生成dest的值...所有内部-字符都将转换为_字符,以确保字符串是有效的属性名称
在本例中,long-option为--batch-size,因此缺省情况下,dest设置为batch_size
https://stackoverflow.com/questions/54812978
复制相似问题