Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1.  
  2. def get_embedded_matrix(max_words,embedding_dim,vocab,embeddings_index):
  3. counter = 0
  4. total_ct = 0
  5. embedding_matrix = np.zeros((max_words, embedding_dim))
  6. for word,index in vocab.items():
  7. total_ct += 1
  8. embedding_vector = embeddings_index.get(word)
  9. if embedding_vector is not None:
  10. embedding_matrix[index] = embedding_vector
  11. counter += 1
  12. else:
  13. embedding_matrix[index] = np.random.uniform(-0.25, 0.25, embedding_dim)
  14. print('Total ',total_ct,' gasit ',counter)
  15. return embedding_matrix
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement