Last active
September 12, 2018 07:23
-
-
Save yaronv/20727dfe1a1488d27572272f02248daf to your computer and use it in GitHub Desktop.
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 get_mean_vector(word2vec_model, words): | |
# remove out-of-vocabulary words | |
words = [word for word in words if word in word2vec_model.vocab] | |
if len(words) >= 1: | |
return np.mean(word2vec_model[words], axis=0) | |
else: | |
return [] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment