Session 会话控制

来源:互联网 发布:长沙学历网络教育报名 编辑:程序博客网 时间:2024/06/05 01:02
import tensorflow as tf# create two matrixesmatrix1 = tf.constant([[3,3]])matrix2 = tf.constant([[2],                       [2]])product = tf.matmul(matrix1,matrix2)# method 1sess = tf.Session()result = sess.run(product)print(result)sess.close()# [[12]]# method 2with tf.Session() as sess:    result2 = sess.run(product)    print(result2)# [[12]]

以上就是我们今天所学的两种 Session 打开模式

原创粉丝点击