Session 会话

Session会话
 
import tensorflow as tf
matrix1 = tf.constant([[3,3]]) #一行两列
marix2 = tf.constant([[2],[2]]) #两行一列
 
product = tf.matmul(matrix1,mattix) #matrix multiply np.dot(m1,m2)
 
#method 1
sess = tf.Session() #Session首字母大写
result = sess.run(product)
print(result)
sess.close()
 
或者
#method 2
with tf.Session() as sess:
result2 = sess.run(product)
print(result2)

猜你喜欢

转载自www.cnblogs.com/renxiaoyan/p/9781180.html