Skip to content

Instantly share code, notes, and snippets.

@paulegradie
Created August 8, 2019 00:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulegradie/8fae6947050c8bc89750d565d0f5732b to your computer and use it in GitHub Desktop.
Save paulegradie/8fae6947050c8bc89750d565d0f5732b to your computer and use it in GitHub Desktop.
# assigns the row from the embedding matrix to the named variable
king = embed_matrix[word_to_index['king']]
male = embed_matrix[word_to_index[‘male’]]
female = embed_matrix[word_to_index[‘female']]
queen = embed_matrix[word_to_index['queen']]
# the formula now uses the vectors from the embedding matrix
assert (king - man) + woman ≈ queen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment