What's the difference between tf.Session() and tf.InteractiveSession()?

前端 未结 4 1734
-上瘾入骨i
-上瘾入骨i 2020-12-12 13:28

In which cases should tf.Session() and tf.InteractiveSession() be considered for what purpose?

When I tried to use the former one, some fun

4条回答
  •  無奈伤痛
    2020-12-12 14:12

    Rather than above mentioned differences - the most important difference is with session.run() we can fetch values of multiple tensors in one step.

    For example:

    num1 = tf.constant(5)
    num2 = tf.constant(10)
    num3 = tf.multiply(num1,num2)
    model = tf.global_variables_initializer()
    
    session = tf.Session()
    session.run(model)
    
    print(session.run([num2, num1, num3]))
    

提交回复
热议问题