在colab笔记本ModuleNotFoundError中运行python脚本

时间:2020-01-10 02:57:47

标签: python google-colaboratory

Colab的新手,我正在尝试在此存储库中重现预训练的BERT模型的微调: https://github.com/ncbi-nlp/ncbi_bluebert

我正在尝试使用以下代码运行run_bluebert_ner.py脚本(从其目录):

!python run_bluebert_ner.py --do_prepare=true \
 --task_name='bc5cdr' \
 --do_train=true \
 --do_eval=true \
 --do_predict=true  \
 --vocab_file=/content/ncbi_bluebert/bluebert_model/vocab.txt \
 --bert_config_file=/content/ncbi_bluebert/bluebert_model/bert_config.json \
 --init_checkpoint=/content/ncbi_bluebert/bluebert_model/bert_model.ckpt.data-00000-of-00001 \
 --data_dir=/content/ncbi_bluebert/data/BC5CDR \
 --num_train_epochs=1.0 \
 --do_lower_case=False \
 --output_dir=output

哪个给我这个错误消息:

Traceback (most recent call last):
  File "run_bluebert_ner.py", line 19, in <module>
    from bluebert.conlleval import evaluate, report_notprint
ModuleNotFoundError: No module named 'bluebert'

我能够将bluebert的内容导入并运行到笔记本本身中。

通过sys.path.extend添加目录的绝对路径无济于事。

搜索了一下之后,我尝试使用:

%run run_bluebert_ner.py --do_prepare=true \
 --task_name='bc5cdr' \
 --do_train=true \
 --do_eval=true \
 --do_predict=true  \
 --vocab_file=/content/ncbi_bluebert/bluebert_model/vocab.txt \
 --bert_config_file=/content/ncbi_bluebert/bluebert_model/bert_config.json \
 --init_checkpoint=/content/ncbi_bluebert/bluebert_model/bert_model.ckpt.data-00000-of-00001 \
 --data_dir=/content/ncbi_bluebert/data/BC5CDR \
 --num_train_epochs=1.0 \
 --do_lower_case=False \
 --output_dir=output

这似乎至少找到了bluebert,但是失败了:

AttributeError: only_check_args

使用FLAGS删除所有标志。 delattr 无济于事。

有人有什么建议吗?

0 个答案:

没有答案