标签:port 会话 mat color on() practice 矩阵乘法 run flow
1 import tensorflow as tf 2 import os 3 os.environ[‘TF_CPP_MIN_LOG_LEVEL‘] = ‘2‘ 4 5 ‘‘‘创建一个常量op‘‘‘ 6 m1 = tf.constant([[3, 3]]) 7 ‘‘‘创建一个常量op‘‘‘ 8 m2 = tf.constant([[2], [3]]) 9 ‘‘‘创建一个矩阵乘法op,把m1,m2传入‘‘‘ 10 product = tf.matmul(m1, m2) 11 print(product) 12 13 ‘‘‘创建一个会话,用于执行矩阵乘法‘‘‘ 14 sess = tf.Session() 15 result = sess.run(product) 16 print(result) 17 sess.close() 18 19 ‘‘‘通过with语句执行完成后,将自动关闭session‘‘‘ 20 with tf.Session() as sess: 21 sess = tf.Session() 22 result = sess.run(product) 23 print(result)
标签:port 会话 mat color on() practice 矩阵乘法 run flow
原文地址:https://www.cnblogs.com/StevenSun1991/p/10134735.html