python - 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.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.
解决方案
这里同样的问题。这是我修复它的方法:
pip install tf_sentencepiece
然后你必须在代码中加载它:
import tensorflow as tf
import tensorflow_hub as hub
import tf_sentencepiece # <- ADD THIS
embed = hub.Module(...)
推荐阅读
- php - HTML表单提交动作转移到php邮件处理程序process.php使用ajax没有收到邮件提交
- html - 如何模糊背景主体?
- clojure - 从命名空间中排除 java.lang.Process
- r - 如何从 SRA 下载 BAM 文件?我有 SRA 工具包,但我很困惑
- roundcube - 您是应该直接修改 Elastic 主题文件,还是复制整个目录来扩展它?
- c++ - c ++函数没有捕获超出范围执行的向量下标
- regex - perl 将字典短语字符串与 / 在其中拆分和组合(以便更好地访问短语条目)
- netweaver - 用户删除日志存储在 SAP 的什么位置?
- bash - 用 \n 和尾随 \n 替换命令输出中的所有 \0
- javascript - bluebird.js 等待 Promise.all(); 在处理程序警告中创建了一个承诺