Created
May 25, 2018 09:59
-
-
Save nokados/b499ad1525eedb3a770756d24b66da0a to your computer and use it in GitHub Desktop.
Embedding Layer for Keras with weights from gensim Word2Vec (or FastText, why not?)
This file contains hidden or 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 word2vec_embedding_layer(embeddings_path='data/weights.npz', max_review_length=150): | |
weights = load_weights(embeddings_path) | |
layer = Embedding(input_dim=weights.shape[0], | |
output_dim=weights.shape[1], | |
input_length=max_review_length, | |
weights=[weights]) | |
return layer | |
# How to make 'data/weights.npz'? What is load_weights()? | |
# See https://gist.github.com/nokados/d5cfec00bc194822f89dff556ff62b29 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment