Python错误:需要以下参数:experimentname

2024-04-19 02:06:34 发布

您现在位置:Python中文网/ 问答频道 /正文

我是Python和PyTorch环境的初学者。我正在GitHub上执行程序。 我得到以下错误:

usage: main.py [-h] [--self_host SELF_HOST] [--cpu] [--port PORT]
               [--server_port SERVER_PORT] [--config CONFIG]
               [--devices_per_trial DEVICES_PER_TRIAL] [--dataroot DATAROOT]
               [--s3 S3] [--logroot LOGROOT] [--seed SEED]
               [--num_eigenthings NUM_EIGENTHINGS] [--batch_size BATCH_SIZE]
               [--eval_batch_size EVAL_BATCH_SIZE] [--momentum MOMENTUM]
               [--num_steps NUM_STEPS] [--max_samples MAX_SAMPLES] [--cuda]
               [--full_dataset] [--fname FNAME] [--mode {power_iter,lanczos}]
               experimentname
main.py: error: the following arguments are required: experimentname
An exception has occurred, use %tb to see the full traceback. 

SystemExit: 2

在%tb时,我得到以下详细信息:

Traceback (most recent call last):

  File "/home/ajinkya/Hessian_Expts/main.py", line 77, in <module>
    skeletor.execute(main)

  File "/home/ajinkya/miniconda3/lib/python3.8/site-packages/skeletor/launcher.py", line 233, in execute
    args = _parser.val.parse_args()

  File "/home/ajinkya/miniconda3/lib/python3.8/argparse.py", line 1768, in parse_args
    args, argv = self.parse_known_args(args, namespace)

  File "/home/ajinkya/miniconda3/lib/python3.8/argparse.py", line 1800, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)

  File "/home/ajinkya/miniconda3/lib/python3.8/argparse.py", line 2034, in _parse_known_args
    self.error(_('the following arguments are required: %s') %

  File "/home/ajinkya/miniconda3/lib/python3.8/argparse.py", line 2521, in error
    self.exit(2, _('%(prog)s: error: %(message)s\n') % args)

  File "/home/ajinkya/miniconda3/lib/python3.8/argparse.py", line 2508, in exit
    _sys.exit(status)

SystemExit: 2

请帮忙消除这个错误。提前谢谢


Tags: inpyselfhomeparsemainlibline
1条回答
网友
1楼 · 发布于 2024-04-19 02:06:34

您的CLI似乎与从^{}公开的CLI不同。无论如何,所有以为前缀的选项都是选项(如 self_host cpu,…)。唯一(必需)的位置参数是experimentname,因此在调用main.py时需要提供它

最低限度的电话是:

python main.py my_experiment

相关问题 更多 >