I used Jupyter Notebook to do ELMo to extract features. However, when I am trying to run the code
!pip install tensorflow
!pip install tensorflow-hub
import tensorflow_hub as hub
import tensorflow as tf
elmo = hub.Module("https://tfhub.dev/google/elmo/2", trainig = True)
it gives error
AttributeError: module 'tensorflow_hub' has no attribute 'Module'
My tensorflow and tensorflow_hub version are:
TensorFlow version: 2.15.0
TensorFlow Hub version: 0.16.1
I've tried to search ways online, but I couldn't find similar error. I think it might because of the versions, and I tried to downgrade the tensorflow, but it still not work.
EDIT 1: Now I am running the code below:
import tensorflow as tf
import tensorflow_hub as hub
elmo = tf.compat.v1.Module("https://tfhub.dev/google/elmo/3", trainable=True)
This is the error I got:
TypeError: Module.__init__() got an unexpected keyword argument 'trainable'
EDIT 2: I am following the example use from elmo model. The code is
elmo = hub.Module("https://www.kaggle.com/models/google/elmo/frameworks/TensorFlow1/variations/elmo/versions/3", trainable=True)
I just replace the hub.Module() using tf.compat.v1.Module, that is why I passing trainable.
However, even I run this code:
elmo = tf.compat.v1.Module("https://tfhub.dev/google/elmo/3")
I got this error:
ValueError: 'https://tfhub.dev/google/elmo/3' is not a valid module name. Module names must be valid Python identifiers (e.g. a valid class name).