Last active
September 17, 2019 16:26
-
-
Save bsod90/a3a5beff80b210b471bf0ddb23e90dda to your computer and use it in GitHub Desktop.
This file contains 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 | |
from tensorflow.saved_model import simple_save | |
export_dir = "./models/use/00000001" | |
with tf.Session(graph=tf.Graph()) as sess: | |
module = hub.Module("https://tfhub.dev/google/universal-sentence-encoder-multilingual-large/1") | |
text_input = tf.placeholder(dtype=tf.string, shape=[None]) | |
sess.run([tf.global_variables_initializer(), tf.tables_initializer()]) | |
embeddings = module(text_input) | |
simple_save(sess, | |
export_dir, | |
inputs={'text': text_input}, | |
outputs={'embeddings': embeddings}, | |
legacy_init_op=tf.tables_initializer()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Have you missed the
import tf_sentencepiece
?