Last active
April 3, 2019 17:09
-
-
Save Tony607/12ea92bb3da4b76ec05f9e5a08932e35 to your computer and use it in GitHub Desktop.
Keras + Universal Sentence Encoder = Transfer Learning for text data | DLology
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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