Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #### 1. tf.Session()不能用.eval()
- ```python
- with tf.Session(graph=g) as sess:
- sess.run(op,feed_dict)
- with tf.Interactive(graph=g) as sess:
- sess.run(op,feed_dict)
- op.eval(feed_dict)
- ```
- #### 2. tf.SessionInteractive()只有一个产生交互活动.eval(),且是最近一个。但两者都可用sess.run同时产生多个活动
- ```python
- g1=tf.Graph()
- g2=tf.Graph()
- with g1.as_default():
- a = tf.constant([1.0, 1.0])
- b = tf.constant([1.0, 1.0])
- result1 = a+b
- with g2.as_default():
- a = tf.constant([2.0, 2.0])
- b = tf.constant([2.0, 2.0])
- result2 = a+b
- sess1 = tf.InteractiveSession(graph=g1)
- sess2 = tf.InteractiveSession(graph=g2)
- out1 = result1.eval() # 错误
- out1 = sess1.run(result1) #正确
- out2 = result2.eval() # 正确
- ```
Add Comment
Please, Sign In to add comment