jupyter 使用parser = argparse.ArgumentParser即add_argument()报错

usage: ipykernel_launcher.py [-h] --task_name TASK_NAME --is_training
                             IS_TRAINING --model_id MODEL_ID --model MODEL
                             --data DATA [--root_path ROOT_PATH]
                             [--data_path DATA_PATH] [--features FEATURES]
                             [--target TARGET] [--checkpoints CHECKPOINTS]
                             [--seq_len SEQ_LEN] [--label_len LABEL_LEN]
                             [--pred_len PRED_LEN]
                             [--seasonal_patterns SEASONAL_PATTERNS]
                             [--mask_rate MASK_RATE]
                             [--anomaly_ratio ANOMALY_RATIO] [--top_k TOP_K]
                             [--num_kernels NUM_KERNELS] [--enc_in ENC_IN]
                             [--dec_in DEC_IN] [--c_out C_OUT]
                             [--d_model D_MODEL] [--n_heads N_HEADS]
                             [--e_layers E_LAYERS] [--d_layers D_LAYERS]
                             [--d_ff D_FF] [--moving_avg MOVING_AVG]
                             [--factor FACTOR] [--distil] [--dropout DROPOUT]
                             [--embed EMBED] [--activation ACTIVATION]
                             [--output_attention] [--num_workers NUM_WORKERS]
                             [--itr ITR] [--train_epochs TRAIN_EPOCHS]
                             [--learning_rate LEARNING_RATE] [--des DES]
                             [--loss LOSS] [--lradj LRADJ] [--use_amp]
                             [--use_gpu USE_GPU] [--gpu GPU] [--use_multi_gpu]
                             [--devices DEVICES] [--data_dir DATA_DIR]
                             [--dataset {dalia,wesad,bami,bami-1,bami-2,ieee}]
                             [--out_dir OUT_DIR] [--n_frames N_FRAMES]
                             [--freq FREQ] [--filter_highcut FILTER_HIGHCUT]
                             [--filter_lowcut FILTER_LOWCUT] [--min_hz MIN_HZ]
                             [--max_hz MAX_HZ] [--n_bins {64,256}]
                             [--sigma_y SIGMA_Y] [--init_lr INIT_LR]
                             [--augmentations AUGMENTATIONS]
                             [--prior {gauss,laplace}]
                             [--uncertainty {entropy,std}]
                             [--batch_size BATCH_SIZE]
                             [--cache_pipeline CACHE_PIPELINE]
                             [--patience PATIENCE] [--use_wandb] [--seed SEED]
                             [--p_hidden_dims P_HIDDEN_DIMS [P_HIDDEN_DIMS ...]]
                             [--p_hidden_layers P_HIDDEN_LAYERS]
ipykernel_launcher.py: error: ambiguous option: --f=/root/.local/share/jupyter/runtime/kernel-v2-30177TejiiBwPXa4a.json could match --features, --factor, --freq, --filter_highcut, --filter_lowcut

根据你提供的代码,你正在尝试使用 argparse 解析命令行参数,并将结果存储在 args_py 变量中
如果你在 Jupyter Notebook 或 JupyterLab 中运行这段代码,并且想要传递命令行参数给 argparse,那么这个方法可能会导致与之前提到的相同的问题。即 Jupyter 内核连接信息被错误解析为命令行参数。
如果你想在 Jupyter Notebook 中定义参数并解析,而不是使用命令行传递参数,我之前给出的建议仍然适用。你可以直接在代码中定义参数,并跳过使用 argparse 解析命令行参数的步骤。然后,你可以手动设置这些参数的值,就像你之前在代码中设置的那样。
以下是在 Jupyter Notebook 中定义参数的示例代码:

args_py = argparse.Namespace()
args_py.task_name = 'estimate'
args_py.is_training = 1
args_py.model_id = 'PPGNet'
args_py.model = 'PPGNet'
args_py.data = 'DaLia'
args_py.root_path = './Data/DaLia/'
args_py.data_path = 'ETTh1.csv'
args_py.target = 'OT'
args_py.checkpoints = './checkpoints/'
# 其他参数...

# 打印参数
print(args_py.task_name)
print(args_py.is_training)
# 其他参数...

你可能感兴趣的:(jupyter,人工智能,算法)