#Session会话控制 #session执行命令,会话控制 import tensorflow as tf matrix1 = tf.constant([[3, 3]]) matrix2 = tf.constant([[2], [2]]) product = tf.matmul(matrix1, matrix2)#矩阵的乘法,在numpy中,矩阵的乘法用np.dot(m1, m2) #method 1 sess = tf.Session() result = sess.run(product) print(result) sess.close() #method 2 #用with最后session会自动关上 with tf.Session() as sess: result2 = sess.run(product) print(result2)
tensorflow之Session
最新推荐文章于 2022-06-03 13:34:01 发布