Skip to content

Instantly share code, notes, and snippets.

@joeyism
Created September 27, 2018 21:02
Show Gist options
  • Save joeyism/626b3e9925185511de9fb46e25ccb350 to your computer and use it in GitHub Desktop.
Save joeyism/626b3e9925185511de9fb46e25ccb350 to your computer and use it in GitHub Desktop.
import tensorflow_hub as hub
import tensorflow as tf
words_to_embed = ["dog", "cat", "sloth"] # <-- it's a list now, and the name changed
elmo = hub.Module("https://tfhub.dev/google/elmo/2")
embedding_tensor = elmo(words_to_embed, as_dict=True)["word_emb"] # <-- passing in a list instead of [word]
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
embedding = sess.run(embedding_tensor)
print(embedding.shape)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment