Skip to content

Instantly share code, notes, and snippets.

@prateekjoshi565
Created March 6, 2019 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prateekjoshi565/5d244ee95987063ee0aab171f99e056d to your computer and use it in GitHub Desktop.
Save prateekjoshi565/5d244ee95987063ee0aab171f99e056d to your computer and use it in GitHub Desktop.
elmo vectors function
def elmo_vectors(x):
embeddings = elmo(x.tolist(), signature="default", as_dict=True)["elmo"]
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
sess.run(tf.tables_initializer())
# return average of ELMo features
return sess.run(tf.reduce_mean(embeddings,1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment