i got this problem with elmo and tensorflow and i wanna fix it without downgrade. what should i do
`**CODE**
import tensorflow_hub as hub
import tensorflow as tf
#Elmo
elmo = hub.Module("https://tfhub.dev/google/elmo/2", trainable=True)
# Provide input tensor and create embeddings
input_tensor = ["my birthday is the best day of the year"]
embeddings_tensor = elmo(input_tensor, signature="default", as_dict=True)["elmo"]
* here i got the problem *
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
embeddings = sess.run(embeddings_tensor)
print(embeddings.shape)
print(embeddings)
`
hub.module()is only compatible withTF 1.xand deprecated from using inTF 2.x. In place of that we can usehub.load()inTF 2.xcode.You can run your code without error by doing following changes in
TF 2.8(or in TF 2.x).Output:
OR the same code can be run using below code above your code (by converting it into
TF 1.x), it will execute successfully: