Skip to content

TF2.0 hub Universal Sentence Encoder Multilingual Sentenepieceop not registered problem #463

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cbahcevan opened this issue Dec 30, 2019 · 5 comments

Comments

@cbahcevan
Copy link

Have I written custom code : No
OS Platform and Distribution : Windows 10 / Google Colab
TensorFlow version (use command below):tensorflow==2.0.0
Python version:Python 3.6.9
Here is my code.

import tensorflow as tf
import tensorflow_hub as hub
import tf_sentencepiece
embedding_layer = hub.load("https://tfhub.dev/google/universal-sentence-encoder-multilingual-large/3")

Problematic output

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/framework/ops.py in _get_op_def(self, type)
   3819     try:
-> 3820       return self._op_def_cache[type]
   3821     except KeyError:

KeyError: 'SentencepieceOp'

During handling of the above exception, another exception occurred:

NotFoundError                             Traceback (most recent call last)
8 frames
/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/framework/ops.py in _get_op_def(self, type)
   3822       with c_api_util.tf_buffer() as buf:
   3823         # pylint: disable=protected-access
-> 3824         c_api.TF_GraphGetOpDef(self._c_graph, compat.as_bytes(type), buf)
   3825         # pylint: enable=protected-access
   3826         data = c_api.TF_GetBuffer(buf)

NotFoundError: Op type not registered 'SentencepieceOp' in binary running on e2f7765a82a9. 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

I could not get answer to this issue on tensorflow respository . I want to get multilingual sentence embeddings using pretrained Google Universal sentence encoder. But I could not able to get it from Windows 10 and Google Colab even if the internet shows diffrent. I was able to get sentence vectors using diffrent hub link like https://tfhub.dev/google/universal-sentence-encoder/4. That is not dependent to sentencepiece.

@Arkin1
Copy link

Arkin1 commented Dec 30, 2019

Hello, I think the multilingual module is dependent on tensorflow_text as stated in this page: https://tfhub.dev/google/universal-sentence-encoder-multilingual/3 .
I have the exact problem myself and it seems that the required library doesn't have support for windows.

@cbahcevan
Copy link
Author

Thank you, now It is working on Google Colab. I added import tensorflow_text line. I gave up on Windows.

@thusithaC
Copy link

adding import tensorflow_text at the top works for me on linux. Thanks for the tip.

@dswah
Copy link

dswah commented Aug 31, 2020

adding import tensorflow_text at the top works for me on linux. Thanks for the tip.

Thanks!
This worked for me too, but is pretty unsatisfying. 😒

@yousefmasry4
Copy link

This worked for me 💯

!python3.8 -m pip install tensorflow_text==2.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants