BERT 模型复现 报错
报错提示信息:NotImplementedError: Cannot convert a symbolic Tensor (bert/encoder/strided_slice:0) to a numpy array.
error 代码:
W0505 17:07:49.208633 140668126729024 error_handling.py:135] Reraising captured error
Traceback (most recent call last):
File "run_classifier.py", line 984, in <module>
tf.app.run()
File "/home/thy/anaconda3/envs/tf115/lib/python3.7/site-packages/tensorflow_core/python/platform/app.py", line 40, in run
_run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
File "/home/thy/anaconda3/envs/tf115/lib/python3.7/site-packages/absl/app.py", line 312, in run
_run_main(main, args)
.............
File "/home/thy/anaconda3/envs/tf115/lib/python3.7/site-packages/tensorflow_core/python/framework/ops.py", line 736, in __array__
" array.".format(self.name))
NotImplementedError: Cannot convert a symbolic Tensor (bert/encoder/strided_slice:0) to a numpy array.
解决方法
降低numpy 版本,例如我的tensorflow是1.15的,numpy版本调整为 1.16.5
ps:选择numpy == 1.16.5 另一个原因是为了满足 scipy (==1.7.3)
另外,建议用pip安装,conda install 会提示调整其他包的版本
pip install numpy==1.16.5