2

I have the following problem mainly due to my lack of expertise with TF in general and TF2.0 in particular.

I try to use Elmo embedding with a keras LSTM implementation.

The code that I am inspired from is using the TF-Hub Elmo module. Which appears to be quite difficult to use if I want to write a 100% TF2.0 Python code.

This is what I have done :

  • I have create the following ElmoEmbedding class but already I am facing the issue on Colab of the eager mode. May I could disable it or should I include the hub.Module call into as default Graph as proposed in the TF2.0 migration documentation ?

Elmo Embedding class from Tf-Hub

  • Now, I have created a tf.function, as I have read that it is the TF2.0 way equivalent to Session.run(). The main question for me, despite the autograph parameter is set to TRUE by default, is how the graph will be passed to the Elmo TF-Hub module...?

Elmo LSTM tf.function

The last call is producting the following error:

Runtime error

oguz ismail
  • 1
  • 16
  • 47
  • 69

1 Answers1

2

I had the same issue and just resolved to using tensorflow 1.15 instead which is compatible with tensorflow-hub.

Otherwise you could maybe look into this:

https://www.tensorflow.org/hub/migration_tf2

msa
  • 693
  • 6
  • 21