Is it possible to use ELMo as a embedding layer with hub.KerasLayer?
If i try:
import tensorflow_hub as hub
import tensorflow as tf
input_tokens = tf.keras.layers.Input(shape=(1000,), name="input_tokens", dtype="string")
sequence_length = tf.constant([1000])
elmo_layer = hub.KerasLayer('https://tfhub.dev/google/elmo/3',
signature='tokens',
output_key='elmo',
trainable=True)
embedding_tokens = elmo_layer(inputs={'tokens': input_tokens,
'sequence_len': sequence_length})
I get the following error message:
_SymbolicException: Inputs to eager execution function cannot be Keras symbolic tensors, but found [<tf.Tensor 'input_tokens_9:0' shape=(None, 1000) dtype=string>]
Is there something I am missing here or is it not possible yet?
@basroelenga ELMO is not available in Tensorflow 2.0 yet but you can use hub.KerasLayer with Tensorflow 1.15 and it works without any error. Please find the gist here
@gowthamkpr Thnx for your response! I indeed got it working in TF 1.15 and was just wondering if it was possible in TF2.0. Is there any timeline for when this will be updated for TF2? Or is it just a waiting game?
@basroelenga Can't give a concrete timeline but keep the community posted on the updates. Closing this issue as it has been resolved.