如何使用SQUAD 2.0训练Xlnet?

时间:2019-08-01 11:31:22

标签: python tensorflow neural-network bert-language-model

我尝试通过运行Xlnet使用SQUAD 2.0在run_squad.py上进行训练和预测 我使用了以下标志:

python run_squad.py   \
--use_tpu=True   \
--num_hosts=1   \
--num_core_per_host=8 \
--model_config_path=/home/jb/xlnet_cased_L-24_H-1024_A-16/xlnet_config.json   \
--spiece_model_file=/home/jb/xlnet_cased_L-24_H-1024_A-16/spiece.model   \
--output_dir=gs://bucket/xlnet_output_tf   \
--init_checkpoint=gs://bucket/xlnet_trained_model/model.ckpt-8000   \
--model_dir=gs://bucket/xlnet_trained_model   \
--train_file=/home/jb/data/train-v2.0.json   \
--predict_file=/home/jb/data/dev-v2.0.json   \
--uncased=False   \
--max_seq_length=512   \
--do_train=False   \
--train_batch_size=48   \
--do_predict=True   \
--predict_batch_size=32   \
--learning_rate=3e-5   \
--adam_epsilon=1e-6   \
--iterations=1000   \
--save_steps=1000   \
--train_steps=8000   \
--warmup_steps=1000   \
--tpu=xlnet

它显示了以下错误:

Traceback (most recent call last):
  File "run_squad.py", line 1310, in <module>
    tf.app.run()
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 40, in run
    _run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
  File "/usr/local/lib/python2.7/dist-packages/absl/app.py", line 300, in run
    _run_main(main, args)
  File "/usr/local/lib/python2.7/dist-packages/absl/app.py", line 251, in _run_main
    sys.exit(main(argv))
  File "run_squad.py", line 1298, in main
    orig_data)
  File "run_squad.py", line 875, in write_predictions
    qid_to_has_ans = squad_utils.make_qid_to_has_ans(orig_data)
  File "/home/jb00557372/xlnet/squad_utils.py", line 42, in make_qid_to_has_ans
    qid_to_has_ans[qa['id']] = bool(qa['answers'])

在训练后以及试图预测dev_v2.0.json的答案时也出现了相同的错误

我正在本地(Linux)加载一些文件,而从Google Cloud Storage Bucket加载一些文件。

我在这里做错了什么?在尝试使用SQUAD 2.0数据集训练BERT之前,我遇到了相同的错误,因为我正在本地加载一些文件。那是问题的原因吗?在shell script for the pre-processing SQUAD dataset中,有bash脚本可使用本地目录创建环境变量。所以我认为是这样。

所有指定的文件都存在于指定的目录中。 TPU已初始化。仅显示此错误。

0 个答案:

没有答案
相关问题