Skip to content

Instantly share code, notes, and snippets.

@yongjun823
Created August 8, 2018 12:18
Show Gist options
  • Select an option

  • Save yongjun823/fa621432c0986754ea51af4def3de81a to your computer and use it in GitHub Desktop.

Select an option

Save yongjun823/fa621432c0986754ea51af4def3de81a to your computer and use it in GitHub Desktop.
tensorflow two session and run run
import tensorflow as tf
import numpy as np
class A:
def __init__(self):
self.X = tf.placeholder(tf.float32, [None, 10])
self.l1 = tf.layers.dense(self.X, 10)
self.sess = tf.Session()
self.sess.run(tf.global_variables_initializer())
def run(self):
print(self.sess.run(self.l1, feed_dict={
self.X: np.ones((3, 10))
}))
a1 = A()
a2 = A()
for i in range(10):
a1.run()
a2.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment