Created
March 6, 2019 18:49
-
-
Save prateekjoshi565/5d244ee95987063ee0aab171f99e056d to your computer and use it in GitHub Desktop.
elmo vectors function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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