python - tensorflow_hub 抛出这个错误 : 'SentencepieceOp' when loading the link

标签 python tensorflow pycharm tensorflow-hub

我试图在 PyCharm 中运行以下代码行,并且安装并导入了 tensorflow_hub。

use = hub.load("https://tfhub.dev/google/universal-sentence-encoder-multilingual-large/3")
对于以下错误有什么建议吗?因为我的项目需要这个。
Traceback (most recent call last):
  File "C:\Users\Jon10\miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\framework\ops.py", line 3820, in _get_op_def
    return self._op_def_cache[type]
KeyError: 'SentencepieceOp'
在处理上述异常的过程中,又发生了一个异常:
Traceback (most recent call last):
  File "C:/Users/Jon10/OneDrive/Documents/Computer Science/Dissertation/PythonPractice/TFTest/test.py", line 28, in <module>
    use = hub.load("https://tfhub.dev/google/universal-sentence-encoder-multilingual-large/3")
  File "C:\Users\Jon10\miniconda3\envs\tensorflow\lib\site-packages\tensorflow_hub\module_v2.py", line 102, in load
    obj = tf_v1.saved_model.load_v2(module_path, tags=tags)
  File "C:\Users\Jon10\miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\saved_model\load.py", line 517, in load
    return load_internal(export_dir, tags)
  File "C:\Users\Jon10\miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\saved_model\load.py", line 541, in load_internal
    export_dir)
  File "C:\Users\Jon10\miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\saved_model\load.py", line 114, in __init__
    meta_graph.graph_def.library))
  File "C:\Users\Jon10\miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\saved_model\function_deserialization.py", line 312, in load_function_def_library
    copy, copy_functions=False)
  File "C:\Users\Jon10\miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\framework\function_def_to_graph.py", line 61, in function_def_to_graph
    fdef, input_shapes, copy_functions)
  File "C:\Users\Jon10\miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\framework\function_def_to_graph.py", line 214, in function_def_to_graph_def
    op_def = ops.get_default_graph()._get_op_def(node_def.op)  # pylint: disable=protected-access
  File "C:\Users\Jon10\miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\framework\ops.py", line 3824, in _get_op_def
    c_api.TF_GraphGetOpDef(self._c_graph, compat.as_bytes(type), buf)
tensorflow.python.framework.errors_impl.NotFoundError: Op type not registered 'SentencepieceOp' in binary running on DESKTOP-..... 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.

最佳答案

需要安装tensorflow_text,并在使用hub.load前导入

关于python - tensorflow_hub 抛出这个错误 : 'SentencepieceOp' when loading the link,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62647139/

相关文章:

python 使用 CDLL 加载 c lib,在 python 路径中看不到库

Python Keras 预测返回 nan

python - 如何使用 Keras RNN 模型预测 future 的日期或事件?

python - pycharm - 如何全局设置高亮级别

pycharm - 在 PyCharm 中禁用自动单元测试

python - 将列表的内容写入文本文件

Python OS PostgreSQL 和引用

python - 在后台运行python文件时没有输出

python - tf.layers.conv1d 与 tf.layers.conv2d 之间的区别

python - 如何在 for 循环中注释类型?