tensorflow2.0 - Tensorflow 2.X 错误 - 在 Colab 上运行的二进制文件中未注册 Op 类型 'CaseFoldUTF8'

标签 tensorflow2.0 bert-language-model

我已经使用 Tensorflow hub 的 BERT 编码器有一段时间了。以下是语法:

tfhub_handle_encoder = "https://tfhub.dev/tensorflow/bert_multi_cased_L-12_H-768_A-12/4" tfhub_handle_preprocess = "https://tfhub.dev/tensorflow/bert_multi_cased_preprocess/3" bert_preprocess_model = hub.KerasLayer(tfhub_handle_preprocess)

突然我遇到了这个错误消息: FileNotFoundError: Op type not registered 'CaseFoldUTF8' in binary running on acb9309ebd87. Make sure the Op and Kernel are registered in the binary running in this process. Note that if you are loading a saved graph which used ops from tf.contrib, accessing (e.g.) tf.contrib.resampler should be done before importing the graph, as contrib ops are lazily registered when the module is first accessed. You may be trying to load on a different device from the computational device. Consider setting the Experimental_io_device option in tf.saved_model.LoadOptions to the io_device such as '/job:localhost'.

相同的代码多年来一直运行良好。 Tf 版本 - 2.9,环境 - Colab/GCP Vertex AI

最佳答案

导入import tensorflow_text as text应该可以解决这个问题。

编辑:您可能需要在 Colab 中运行 !pip install tensorflow_text

关于tensorflow2.0 - Tensorflow 2.X 错误 - 在 Colab 上运行的二进制文件中未注册 Op 类型 'CaseFoldUTF8',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75576980/

相关文章:

tensorflow - TF2 - GradientTape 与 Model.fit() - 为什么 GradientTape 不起作用?

python - 迭代 tf.data.Dataset 的有效方法

python - 为什么 tf.executing_eagerly() 在 TensorFlow 2 中返回 False?

python - TFX Example_Gen 产生运行时错误

nlp - 关于 BertForMaskedLM

python - 在输出和目标标签之间使用 nn.Cross entropy

python - 当想要查找得分最高的 `start` 标记时,torch.argmax() 中出现 TypeError

python - 如何打印 Keras 张量值?