我该怎么补救呢?
parser = argparse.ArgumentParser()
parser.add_argument("mode", help="Trains or tests the CNN", nargs="*", choices=["train", "continue", "test", "confusionmatrix", "vote", "slice"])
parser.add_argument("--resume", help="The version to continue training from", required=False, default=False)
parser.add_argument("--epochs", help="The number of epochs to finish training from", type=int, required=False, default=False)
args = parser.parse_args()
print("args", args)
我试过了
*args, unknown = parser.parse_known_args()
但没有用
1条答案
按热度按时间zf9nrax11#
参数值不能为空。如果您的正确值是其中之一[“train”,“continue”,“test”,“confusionmatrix”,“vote”,“slice”],则必须如下所示:
您可以将“confusionmatrix”替换为其中的任何一个[“train”、“continue”、“test”、“confusionmatrix”、“vote”、“slice”]
如果出现系统退出:2你可以这样试试:
您需要在“arg_parse.add_argument“行的末尾添加[ parser.add_argument(“-f”,required=False)]