tensorflow/text

Tensorflow importing problem in Google colab

Opened this issue · 1 comments

When i try to import tensorflow_hub with tensorflow_text,I get attribute error for tensorflow_hub.The error looks like:
AttributeError Traceback (most recent call last)
in <cell line: 2>()
1 import tensorflow as tf
----> 2 import tensorflow_hub as hub
3 import tensorflow_text as text

13 frames
/usr/local/lib/python3.10/dist-packages/tf_keras/src/saving/legacy/saved_model/load_context.py in
66
67
---> 68 tf.internal.register_load_context_function(in_load_context)
69

AttributeError: module 'tensorflow._api.v2.compat.v2.internal' has no attribute 'register_load_context_function'.

I have upgrade tensorflow,uninstalled it again but I am getting this error over and over again.I have also changed the running type from cpu to gpu and tpu.But nothing seems to working.

I had the same problem. Fixed it by using a previous version of tensorflow-text

!pip install tensorflow-text==2.15.0

I think it's from keras version used by colab that is not compatible with latest tensorflow (version must be below 2.16 and above 2.15 but newest is currently 2.16.1). Not an expert thought, hope it helps