python注册表Tensorflow中缺少图形操作
我正在尝试使用通用句子编码器多语言模块。我使用的是tensorflow 1.14版本。在提到有关stackoverflow的其他问题后,一个可能的原因是使用旧版本的tensorflow,这里的情况并非如此 更新:添加了python包版本python注册表Tensorflow中缺少图形操作,python,tensorflow,Python,Tensorflow,我正在尝试使用通用句子编码器多语言模块。我使用的是tensorflow 1.14版本。在提到有关stackoverflow的其他问题后,一个可能的原因是使用旧版本的tensorflow,这里的情况并非如此 更新:添加了python包版本 ### Tensorflow version : 1.14.0 ### sentencepiece: 0.1.82 ### tf-sentencepiece: 0.1.82.1 use_large_module_url = "https://tfhub.
### Tensorflow version : 1.14.0
### sentencepiece: 0.1.82
### tf-sentencepiece: 0.1.82.1
use_large_module_url = "https://tfhub.dev/google/universal-sentence-encoder-large/3" #@param ["https://tfhub.dev/google/universal-sentence-encoder/2", "https://tfhub.dev/google/universal-sentence-encoder-large/3"]
use_lite_module_url = "https://tfhub.dev/google/universal-sentence-encoder-lite/2"
use_multilingual_url = 'https://tfhub.dev/google/universal-sentence-encoder-multilingual/1' #@param ['https://tfhub.dev/google/universal-sentence-encoder-multilingual/1', 'https://tfhub.dev/google/universal-sentence-encoder-multilingual-large/1', 'https://tfhub.dev/google/universal-sentence-encoder-xling-many/1']
# embed = hub.Module(use_lite_module_url)
# embed = hub.Module(use_large_module_url)
embed = hub.Module(use_multilingual_url)
错误
---------------------------------------------------------------------------
NotFoundError Traceback (most recent call last)
<ipython-input-11-22dba73760e9> in <module>()
5 # embed = hub.Module(use_lite_module_url)
6 # embed = hub.Module(use_large_module_url)
----> 7 embed = hub.Module(use_multilingual_url)
3 frames
/usr/local/lib/python3.6/dist-packages/tensorflow_hub/module.py in __init__(self, spec, trainable, name, tags)
168 name=self._name,
169 trainable=self._trainable,
--> 170 tags=self._tags)
171 # pylint: enable=protected-access
172
/usr/local/lib/python3.6/dist-packages/tensorflow_hub/native_module.py in _create_impl(self, name, trainable, tags)
338 trainable=trainable,
339 checkpoint_path=self._checkpoint_variables_path,
--> 340 name=name)
341
342 def _export(self, path, variables_saver):
/usr/local/lib/python3.6/dist-packages/tensorflow_hub/native_module.py in __init__(self, spec, meta_graph, trainable, checkpoint_path, name)
380
381 register_ops_if_needed({
--> 382 op.name for op in self._meta_graph.meta_info_def.stripped_op_list.op})
383
384 if _is_tpu_graph_function():
/usr/local/lib/python3.6/dist-packages/tensorflow_hub/native_module.py in register_ops_if_needed(graph_ops)
820 "Graph ops missing from the python registry (%s) are also absent from "
821 "the c++ registry."
--> 822 % missing_ops.difference(set(cpp_registry_ops.keys())))
823
824
NotFoundError: Graph ops missing from the python registry ({'SentencepieceEncodeSparse'}) are also absent from the c++ registry.
---------------------------------------------------------------------------
NotFoundError回溯(最近一次调用上次)
在()
5#embed=hub.Module(使用_lite_Module_url)
6#embed=hub.Module(使用大模块url)
---->7嵌入=集线器模块(使用多语言url)
3帧
/usr/local/lib/python3.6/dist-packages/tensorflow\u hub/module.py in\uuuuuuuu init\uuuuuuuu(self、spec、trainiable、name、tags)
168 name=self.\u name,
169可培训=可自我培训,
-->170个标签=自身。\u标签)
171#pylint:enable=受保护访问
172
/usr/local/lib/python3.6/dist-packages/tensorflow\u hub/native\u module.py in\u create\u impl(self、name、trainable、tags)
338可培训=可培训,
339检查点路径=自身检查点变量路径,
-->340名称=名称)
341
342定义导出(自身、路径、变量):
/usr/local/lib/python3.6/dist-packages/tensorflow\u hub/native\u module.py in\uuuuuuuuuu init\uuuuuuuuuu(self、spec、meta\u图、可训练、检查点路径、名称)
380
381如果需要,注册操作({
-->382自我中op的op.name._meta_graph.meta_info_def.stripped_op_list.op})
383
384如果_是_tpu图_函数():
/usr/local/lib/python3.6/dist-packages/tensorflow\u hub/native\u module.py(如果需要)(图\u ops)
820“python注册表中缺少的图形操作(%s)也缺少”
821“C++注册表”。
-->822%缺少操作差异(设置(cpp\u注册表操作键()))
823
824
No.PoxDrror:从Python注册表中丢失的图OPS({ StEncEnCEECONDECODES PARSE)}也不存在于C++注册表中。
在Windows中,我相信目前没有可用的解决方案,但如果您使用Linux/Ubuntu,请尝试以下方法:
TFHUB_CACHE_DIR=/data/models/tf-hub
(数据/模型是您的本地路径,请随意更改)
创建一个环境变量,然后
source ~/.bashrc
以反映变化。祝你好运这里也有同样的问题。下面是我如何修复它的:
pip install tf_sentencepiece
然后你必须在代码中加载它:
import tensorflow as tf
import tensorflow_hub as hub
import tf_sentencepiece # <- ADD THIS
embed = hub.Module(...)
将tensorflow导入为tf
将tensorflow_hub导入为hub
导入tf_sentencepiece#您是否安装并导入了sentencepiece
和tf_sentencepiece
?@James我已在此处更新了描述相同错误。谷歌搜索了一段时间,但没有找到任何解决方案:“TysFrace.python .Frrase.ErrrsSy.In.NoxFunDror:从Python注册表中丢失的图OPS({ StEncEnCEECONDECODES PARSE)}也不存在于C++注册表中。