1.2Tensorflow的Session操作
tf的session
#-*- coding: utf-8 -*- # @Time : 2017/12/21 14:56 # @Author : Z # @Email : S # @File : 1.1session.py #session import tensorflow as tf matrix1=tf.constant([[3,3]]) #1*2列 matrix2=tf.constant([[2], #2*1列 [2]]) result=tf.matmul(matrix1,matrix2) #矩阵的乘法\ # print result #方式1---直接定义 # sess=tf.Session() # result1 =sess.run(result) # #每次run才会执行上述的矩阵乘法结构 # print(result1) # sess.close() #方式2--打开了session以sess命名,不需要sess.close,执行完自动关闭 with tf.Session() as sess: result2=sess.run(result) print (result2)
博客地址:http://www.cnblogs.com/jackchen-Net/