Reputation: 23
I got this error while trying to run bertseq2seq from TFHub on Colab. Please help with this error. (I am trying on colab because I already use TF2 in my machine and don't want to mess that up by downgrading or having parallel TF1. If it works out then I will try installing TF1 in a server)
%tensorflow_version 1.x
import tensorflow.compat.v1 as tf
import tensorflow_hub as hub
import tensorflow_text
#### Sentence Fusion #########
text_generator = hub.Module(
'https://tfhub.dev/google/bertseq2seq/roberta24_discofuse/1')
Upvotes: 0
Views: 812
Reputation: 603
I cannot reproduce the issue using your snippet and a fresh Colab notebook but the following code works for me in Colab:
# You can achieve TF1 behavior by still using a TF2 installation using the
# compat API. See the Migration Guide (https://www.tensorflow.org/guide/migrate)
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
!pip install tensorflow_text
import tensorflow_hub as hub
import tensorflow_text
text_generator = hub.Module('https://tfhub.dev/google/bertseq2seq/roberta24_discofuse/1')
input_texts = ['Sentence 1a. Sentence 1b.', 'Sentence 2a. Sentence 2b. Sentence 2c.']
with tf.Session() as sess:
sess.run(tf.group(tf.global_variables_initializer(), tf.tables_initializer()))
print(sess.run(text_generator(input_texts)))
# [b'Sentence 1a. Sentence 1b' b'Sentence 2a. Sentence 2b. Sentence 2c']
Upvotes: 0