Created
June 8, 2019 09:32
-
-
Save oborchers/7d6dfd91f995e44fd37cdb0e8a6446b7 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 sif_embeddings(sentences, model): | |
""" Uses a pre-computed list of indices and skips the use of strings alltogether | |
""" | |
vectors = model.wv.sif_vectors | |
output = np.zeros(shape=(len(sentences), model.vector_size), dtype=REAL) | |
for i,s in enumerate(sentences): | |
output[i] = np.sum(vectors[s], axis=0) * ( (1/len(s)) if len(s)>0 else 1) | |
return output.astype(REAL) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment