Skip to content

Instantly share code, notes, and snippets.

@jainanchit51
Created February 3, 2019 08:48
Show Gist options
  • Save jainanchit51/9ee6810b3b7bfc47ad668c7f08cda88b to your computer and use it in GitHub Desktop.
Save jainanchit51/9ee6810b3b7bfc47ad668c7f08cda88b to your computer and use it in GitHub Desktop.
import tensorflow as tf
import tensorflow_hub as hub
# enabling the pretrained model for trainig our custom model using tensorflow hub
module_url = "https://tfhub.dev/google/universal-sentence-encoder-large/3"
embed = hub.Module(module_url)
# creating a method for embedding and will using method for every input layer
def UniversalEmbedding(x):
return embed(tf.squeeze(tf.cast(x, tf.string)), signature="default", as_dict=True)["default"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment