大家有时候在阅读代码时会看见InteractiveSession而不是熟悉的Session,这是什么东东呢?

其实,它们只有一点不同。。。。。

InteractiveSession是默认的session,这就意味着你可以在不声明session的条件下直接使用run(),eval() 。这在interactive shellsIPython notebooks 中非常方便!

上例子:

1 sess = tf.InteractiveSession()
2 a = tf.constant(5.0)
3 b = tf.constant(6.0)
4 c = a * b
5 # We can just use 'c.eval()' without passing 'sess'
6 print(c.eval())
7 sess.close()

 

相关文章:

  • 2021-10-26
  • 2021-12-25
  • 2021-07-18
  • 2021-12-10
  • 2021-04-10
  • 2021-11-18
  • 2021-04-12
猜你喜欢
  • 2021-08-14
  • 2022-12-23
  • 2022-12-23
  • 2021-08-22
  • 2021-08-01
  • 2021-10-17
  • 2021-08-22
相关资源
相似解决方案