zoukankan      html  css  js  c++  java
  • tensorflow函数解析: tf.Session() 和tf.InteractiveSession()

    链接如下:

    http://stackoverflow.com/questions/41791469/difference-between-tf-session-and-tf-interactivesession

    英文

    Question:

    Questions says everything, for taking sess= tf.Session() and sess=tf.InteractiveSession() which cases should be considered for what purpose ? When I am using former one some function didn't work and when changed to the later it worked (for example .eval()).

    Answer:

    Mainly taken from official documentation:

    The only difference with a regular Session is that an InteractiveSession installs itself as the default session on construction. The methods Tensor.eval() and Operation.run() will use that session to run ops.

    This allows to use interactive context, like shell, as it avoids having to pass an explicit Session object to run op:

    sess = tf.InteractiveSession()
    a = tf.constant(5.0)
    b = tf.constant(6.0)
    c = a * b
    # We can just use 'c.eval()' without passing 'sess'
    print(c.eval())
    sess.close()
    

    It is also possible to say, that InteractiveSession supports less typing, as allows to run variables without needing to constantly refer to the session object.

     

    中文

    问题: tf.Session()和tf.InteractiveSession()的区别?

    答案:

    唯一的区别在于:tf.InteractiveSession()加载它自身作为默认构建的session,tensor.eval()和operation.run()取决于默认的session.

    换句话说:InteractiveSession 输入的代码少,原因就是它允许变量不需要使用session就可以产生结构。

  • 相关阅读:
    bzoj 1497 最小割模型
    bzoj 1024 暴力深搜
    POJ1163(简单的DP)
    POJ3287(BFS水题)
    N皇后问题(DFS)
    BFS求解迷宫的最短路径问题
    poj2386(简单的dfs/bfs)
    Fence Repair(poj3253)
    Best cow Line(POJ 3617)
    全排列
  • 原文地址:https://www.cnblogs.com/antflow/p/7234213.html
Copyright © 2011-2022 走看看