Last active
September 7, 2019 10:45
-
-
Save VictorSaenger/7c9f1afa0060768535c845cb3c77a9d8 to your computer and use it in GitHub Desktop.
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
| #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