Skip to content

Instantly share code, notes, and snippets.

@VictorSaenger
Last active September 7, 2019 10:45
Show Gist options
  • Select an option

  • Save VictorSaenger/7c9f1afa0060768535c845cb3c77a9d8 to your computer and use it in GitHub Desktop.

Select an option

Save VictorSaenger/7c9f1afa0060768535c845cb3c77a9d8 to your computer and use it in GitHub Desktop.
#This code is a cheap adaptation of example code from tf's hub website:
# More at: https://tfhub.dev/google/universal-sentence-encoder-multilingual/1
#Initialize tf graph:
g = tf.Graph()
with g.as_default():
text_input = tf.placeholder(dtype=tf.string, shape=[None])
#Here you can specify your path
embed = hub.Module('/path/to/model/')
#Or downlload it directly from tf's hub:
# embed = hub.Module("https://tfhub.dev/google/universal-sentence-encoder-multilingual/1")
embedded_text = embed(text_input)
init_op = tf.group([tf.global_variables_initializer(), tf.tables_initializer()])
g.finalize()
# Initialize session.
session = tf.Session(graph=g)
session.run(init_op)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment