Skip to content

Instantly share code, notes, and snippets.

@yashkumaratri
Forked from Tony607/embed.py
Created April 3, 2019 17:09
Show Gist options
  • Save yashkumaratri/8f6c7966d1db0df1e87a0e3451707ffd to your computer and use it in GitHub Desktop.
Save yashkumaratri/8f6c7966d1db0df1e87a0e3451707ffd 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