Skip to content

Instantly share code, notes, and snippets.

@Tony607
Last active April 3, 2019 17:09
Show Gist options
  • Save Tony607/12ea92bb3da4b76ec05f9e5a08932e35 to your computer and use it in GitHub Desktop.
Save Tony607/12ea92bb3da4b76ec05f9e5a08932e35 to your computer and use it in GitHub Desktop.
Keras + Universal Sentence Encoder = Transfer Learning for text data | DLology
import tensorflow as tf
import tensorflow_hub as hub
module_url = "https://tfhub.dev/google/universal-sentence-encoder-large/3"
# Import the Universal Sentence Encoder's TF Hub module
embed = hub.Module(module_url)
# Compute a representation for each message, showing various lengths supported.
messages = ["That band rocks!", "That song is really cool."]
with tf.Session() as session:
session.run([tf.global_variables_initializer(), tf.tables_initializer()])
message_embeddings = session.run(embed(messages))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment