用pytorch运行github上谷歌提供的bert模型的run_classifier.py,参数见官网,需将其中有$的参数进行替换,替换成自己的路径,运行过程会出现以下错误:
1.cannot import name ‘modeling’ from ‘bert’
将import modeling import optimization import tokenization
改为from bert import modeling from bert import optimization from bert import tokenization
2.No module named ‘bert_serving’
解决方案
pip install bert-serving-server --user
pip install bert-serving-client --user
3.pip install bert
ImportError: cannot import name ‘modeling’ from ‘bert’ (C:\ProgramData\Anaconda3\lib\site-packages\bert_init_.py)
解决方案:pip install bert-tensorflow
4.tensorflow小于1.11.0会报错,但是1.11.0又没法直接安装,所以安装1.13.1,实践没出错(时间:2021/1/17)
pip uninstall tensorflow
pip install tensorflow==1.13.1
参考:https://www.cnblogs.com/z-cm/p/13021569.html