Guest User

Untitled

a guest
Jul 19th, 2018
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #### 1. tf.Session()不能用.eval()
  2. ```python
  3. with tf.Session(graph=g) as sess:
  4. sess.run(op,feed_dict)
  5.  
  6. with tf.Interactive(graph=g) as sess:
  7. sess.run(op,feed_dict)
  8. op.eval(feed_dict)
  9. ```
  10.  
  11. #### 2. tf.SessionInteractive()只有一个产生交互活动.eval(),且是最近一个。但两者都可用sess.run同时产生多个活动
  12. ```python
  13. g1=tf.Graph()
  14. g2=tf.Graph()
  15. with g1.as_default():
  16. a = tf.constant([1.0, 1.0])
  17. b = tf.constant([1.0, 1.0])
  18. result1 = a+b
  19. with g2.as_default():
  20. a = tf.constant([2.0, 2.0])
  21. b = tf.constant([2.0, 2.0])
  22. result2 = a+b
  23. sess1 = tf.InteractiveSession(graph=g1)
  24. sess2 = tf.InteractiveSession(graph=g2)
  25. out1 = result1.eval() # 错误
  26. out1 = sess1.run(result1) #正确
  27. out2 = result2.eval() # 正确
  28. ```
Add Comment
Please, Sign In to add comment