error: unrecognized arguments:

传递参数后最后显示的错误是main.py: error: unrecognized arguments: --visual_element_choice story。查了半天没有解决,大神知道这应该怎么改吗?

**-desktop:~/newspace2/znq/PR_VIST_main/story_plotting/script$ bash run_generation.sh

  • python3 ../src/main.py --model HR_BiLSTM_plus --dataset vist --framework UHop --earlystop_tolerance 20 --saved_dir saved_model --dynamic none --reduce_method dense --emb_size 300 --hidden_size 150 --dropout_rate 0.2 --optimizer rmsprop --neg_sample 1024 --l2_norm 0.0 --margin 0.5 --hop_weight 1 --task_weight 1 --acc_weight 1 --q_representation lstm --generation --path ../story_plotting/HR_BiLSTM_plus_36 --path_search --termset_sample_size 1000 --sample_size 40 --device 1 --term_path new_obj --file_type test --is_image_abs_position --repetitve_penalty 0.9 --empty_frame_penalty 1.0 --relation_frequency 10 --is_restrict_vocab --only_five2seven_sentences --graph_choice multi-graph --visual_element_choice story
    usage: main.py [-h] [--model MODEL] [--framework FRAMEWORK]
             (--train | --test | --generation) [--emb_size EMB_SIZE]
             [--path PATH] [--epoch_num EPOCH_NUM]
             [--hidden_size HIDDEN_SIZE] [--num_filters NUM_FILTERS]
             [--neg_sample NEG_SAMPLE] [--dropout_rate DROPOUT_RATE]
             [--learning_rate LEARNING_RATE] [--optimizer OPTIMIZER]
             [--l2_norm L2_NORM] [--earlystop_tolerance EARLYSTOP_TOLERANCE]
             [--margin MARGIN] [--train_step_1_only TRAIN_STEP_1_ONLY]
             [--train_rela_choose_only TRAIN_RELA_CHOOSE_ONLY]
             [--show_result SHOW_RESULT] [--train_embedding TRAIN_EMBEDDING]
             [--log_result LOG_RESULT] [--dataset DATASET]
             [--saved_dir SAVED_DIR] [--hop_weight HOP_WEIGHT]
             [--task_weight TASK_WEIGHT] [--acc_weight ACC_WEIGHT]
             [--stop_when_err] [--step_every_step] [--dynamic DYNAMIC]
             [--only_one_hop] [--reduce_method REDUCE_METHOD]
             [--pretrained_bert PRETRAINED_BERT]
             [--q_representation Q_REPRESENTATION] [--device DEVICE]
             [--occurrence OCCURRENCE] [--path_search]
             [--termset_sample_size TERMSET_SAMPLE_SIZE]
             [--sample_size SAMPLE_SIZE] [--abs_position] [--ethan_position]
             [--is_sampling] [--recurrent_UHop]
             [--term_path {AAAI,new_obj,noun_only}] [--force_one_noun]
             [--story_noun_query] [--is_image_abs_position]
             [--is_seperate_structural] [--is_term_only]
             [--file_type FILE_TYPE] [--is_story_noun_candidate]
             [--constant_padding] [--rela_size RELA_SIZE]
             [--rela_text_size RELA_TEXT_SIZE] [--prepend] [--small]
             [--only_five_sentences] [--only_four2six_sentences]
             [--repetitve_penalty REPETITVE_PENALTY] [--ten_obj]
             [--is_KG_only] [--no_reverse] [--is_restrict_vocab]
             [--empty_frame_penalty EMPTY_FRAME_PENALTY]
             [--is_start_end_frame] [--relation_frequency {10,20,30}]
             [--is_beam_search_graph] [--only_five2seven_sentences]
             [--only_six2seven_sentences] [--over5]
             [--graph_choice {multi-graph,vg-graph,vist-graph}]
    
    main.py: error: unrecognized arguments: --visual_element_choice story

【以下回答由 GPT 生成】

这个错误是由于main.py脚本中没有定义--visual_element_choice参数导致的。要解决这个错误,你可以按照以下步骤进行操作:

  1. 打开main.py脚本文件。
  2. 在脚本文件的顶部找到argparse模块的import语句,应该类似于import argparse
  3. 在import语句下面的代码中找到argparse.ArgumentParser()的实例化部分,通常是: python parser = argparse.ArgumentParser()
  4. 在实例化后的parser对象下添加一个--visual_element_choice参数的定义。 python parser.add_argument('--visual_element_choice', type=str, help='description of the visual element choice argument') 更换'description of the visual element choice argument'为实际的参数描述。
  5. 保存并关闭main.py脚本文件。
  6. 再次运行你的命令: bash python3 ../src/main.py --model HR_BiLSTM_plus --dataset vist --framework UHop --earlystop_tolerance 20 --saved_dir saved_model --dynamic none --reduce_method dense --emb_size 300 --hidden_size 150 --dropout_rate 0.2 --optimizer rmsprop --neg_sample 1024 --l2_norm 0.0 --margin 0.5 --hop_weight 1 --task_weight 1 --acc_weight 1 --q_representation lstm --generation --path ../story_plotting/HR_BiLSTM_plus_36 --path_search --termset_sample_size 1000 --sample_size 40 --device 1 --term_path new_obj --file_type test --is_image_abs_position --repetitve_penalty 0.9 --empty_frame_penalty 1.0 --relation_frequency 10 --is_restrict_vocab --only_five2seven_sentences --graph_choice multi-graph --visual_element_choice story 这样,你的命令应该就能正常运行了。

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^