3👍
Load your model with the graph that you created and use that in your session.
graph = tf.Graph()
with tf.Session(graph = graph) as session:
embed = hub.Module("https://tfhub.dev/google/universal-sentence-encoder/2")
And use the same graph object in initiate_connection function with session
def initiate_connection(conn):
data = conn.recv(1024)
with tf.Session(graph = graph) as session:
session.run([tf.global_variables_initializer(), tf.tables_initializer()])
conn.send(session.run(embed([data])))
conn.close()
Source:stackexchange.com