使用 BERT 模型,我不断收到错误:在 MacBook-Pro-21.lan 上运行的二进制文件中,Op 类型未注册“CaseFoldUTF8”

问题描述 投票:0回答:1

我正在尝试使用 BERT 模型来帮助预测更新是否紧急。我能够通过以下输出标记更新:

但是,当我去定义模型时,我不断收到

CASEFOLDUTF8
错误。所有软件包均已更新,我已在 Docker 和 google colab 中尝试过,最佳运行 applemacbook m2 芯片。

运行时错误:在 MacBook-Pro-21.local 上运行的二进制文件中,操作类型未注册“CaseFoldUTF8”。确保 Op 和 Kernel 已在此进程中运行的二进制文件中注册。请注意,如果您要加载使用 tf.contrib 中的操作的已保存图形(例如

tf.contrib.resampler
),则应在导入图形之前完成访问,因为首次访问模块时会延迟注册 contrib 操作。

更新了张量流,结果相同。重新启动内核,结果相同。在google colab中尝试过,结果相同。

python nlp data-mining bert-language-model
1个回答
0
投票

我在Google Colab中遇到了类似的问题。这是一个 pip 依赖错误问题。我解决问题的步骤:

!pip install --quiet tensorflow
!pip install --quiet tf-keras~=2.16
!pip install --quiet tensorflow_text

#after running above command in different cell
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
import random
import tensorflow as tf
import tf_keras as keras
import tensorflow_text
print(tf.__version__) #o/p to latest tf version from Google colab

#code from TF.org for BERT text classification
# load pre-processing model and BERT
preprocess = hub.load('https://kaggle.com/models/tensorflow/bert/frameworks/TensorFlow2/variations/en-uncased-preprocess/versions/3')
bert = hub.load('https://www.kaggle.com/models/google/experts-bert/frameworks/TensorFlow2/variations/pubmed/versions/2') #will run with no error

希望这有帮助! 谢谢, 乔丹

© www.soinside.com 2019 - 2024. All rights reserved.