Skip to content

Instantly share code, notes, and snippets.

@alierkan
Forked from mbednarski/w2v.ipynb
Created December 10, 2020 13:42
Show Gist options
  • Save alierkan/f4243e95ec4214117d3610dce28fdb05 to your computer and use it in GitHub Desktop.
Save alierkan/f4243e95ec4214117d3610dce28fdb05 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@alierkan
Copy link
Author

def similarity(v,u):
return torch.dot(v,u)/(torch.norm(v)*torch.norm(u))

similarity(W2[word2idx["she"]], W2[word2idx["king"]])
similarity(W2[word2idx["she"]], W2[word2idx["queen"]])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment