Skip to content

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

Closed

Description

@cbahcevan

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.

Activity

  1. Arkin1 commented on Dec 30, 2019

    @Arkin1

    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.

  2. cbahcevan commented on Dec 30, 2019

    @cbahcevan
    Author

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

  3. thusithaC commented on Mar 17, 2020

    @thusithaC

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

  4. dswah commented on Aug 31, 2020

    @dswah

    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. 😒

  5. yousefmasry4 commented on Apr 21, 2021

    @yousefmasry4

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions