AttributeError: module ‘transformers’ has no attribute ‘TFBertModel’

我的环境是通过Pycharm创建的,包含以下软件包:tensorflow==1.13.0rc1,CUDA = 11 以及相应的cudn。但是运行 https://github.com/keras-team/keras-io/blob/master/examples/nlp/semantic_similarity_with_bert.py 文件的第1行到第269行,并执行print(f”Strategy: {strategy}”)和model.summary()后,报告了以下错误:

2021-08-29 00:16:22.311887: I tensorflow/core/platform/cpu_feature_guard.cc:141] 您的CPU支持的指令集与此TensorFlow二进制文件的编译不匹配:AVX2WARNING:tensorflow:在`tf.distribute.Strategy`中的所有设备并非TensorFlow可见。Traceback (most recent call last):  File "D:/.../PycharmProjects/.../Semantic Similarity with BERT.py", line 190, in <module>    bert_model = transformers.TFBertModel.from_pretrained("bert-base-uncased")AttributeError: module 'transformers' has no attribute 'TFBertModel'

回答:

Tensorflow 2.6.0 可以正常工作

pip install transformerspip install tensorflow from transformers import BertModel, TFBertModel

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注