Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_embedded_matrix(max_words,embedding_dim,vocab,embeddings_index):
- counter = 0
- total_ct = 0
- embedding_matrix = np.zeros((max_words, embedding_dim))
- for word,index in vocab.items():
- total_ct += 1
- embedding_vector = embeddings_index.get(word)
- if embedding_vector is not None:
- embedding_matrix[index] = embedding_vector
- counter += 1
- else:
- embedding_matrix[index] = np.random.uniform(-0.25, 0.25, embedding_dim)
- print('Total ',total_ct,' gasit ',counter)
- return embedding_matrix
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement