I am trying to use universal sentence encoder multilingual module. I am using tensorflow 1.14 version. After referring to other questions on stackoverflow, one possible reason was using old version of tensorflow, which is not the case here.
Update: Added python packages version
### 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)
Error
---------------------------------------------------------------------------
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.
Same issue here. Here's how I fixed it:
pip install tf_sentencepiece
and then you have to load it inside code:
import tensorflow as tf
import tensorflow_hub as hub
import tf_sentencepiece # <- ADD THIS
embed = hub.Module(...)
In Windows I believe there is no solution available at this moment, but if you are in Linux/Ubuntu try the following:
TFHUB_CACHE_DIR=/data/models/tf-hub
(data/models is your local path, change it as you please)
And create one environment variable, and then
source ~/.bashrc
To reflect changes. Good luck
From the error msg it's not evident. To resolve this error do the below
pip install tensorflow_text
and in your python script import
import tensorflow_text as tf_txt
This should resolve the above error.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.