Skip to content

Instantly share code, notes, and snippets.

@hamletbatista
Created December 3, 2019 20:43
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 hamletbatista/398da7a634db206bd422ead1f8999b78 to your computer and use it in GitHub Desktop.
Save hamletbatista/398da7a634db206bd422ead1f8999b78 to your computer and use it in GitHub Desktop.
import tensorflow_hub as hub
embed = hub.load("https://tfhub.dev/google/universal-sentence-encoder/3")
embeddings = embed([
"The quick brown fox jumps over the lazy dog.",
"I am a sentence for which I would like to get its embedding"])["outputs"]
print embeddings
# The following are example embedding output of 512 dimensions per sentence
# Embedding for: The quick brown fox jumps over the lazy dog.
# [-0.03133016 -0.06338634 -0.01607501, ...]
# Embedding for: I am a sentence for which I would like to get its embedding.
# [0.05080863 -0.0165243 0.01573782, ...]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment