问题:
在Jupyter Notebook中使用args传递参数时出现错误:
原始代码:args = parser.parse_args()
usage: ipykernel_launcher.py [-h] [--x_dim XDIM] [--h_dim HDIM] [--z_dim ZDIM]
[--ratio RATIO] [--seed SEED]
ipykernel_launcher.py: error: unrecognized arguments: -f C:\Users\MSI-NBOOK\AppData\Roaming\jupyter\runtime\kernel-f881e2bc-0a12-4207-b4cf-1cf484ec88f2.json
An exception has occurred, use %tb to see the full traceback.
SystemExit: 2
F:\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py:2971: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.
warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)
解决办法:
将原始代码进行修改,修改后为:
args = parser.parse_args(args=[])
修改后即可使用。