import tensorflow as tf
import warnings
warnings.filterwarnings('ignore')
# 创建一个常量
m1 = tf.constant([[3,3]])
# 创建一个常量
m2 = tf.constant([[2],[3]])
# 矩阵乘法op
product = tf.matmul(m1, m2)
print(product)
输出:
Tensor("MatMul_3:0", shape=(1, 1), dtype=int32)
# 定义会话
sess = tf.Session()
# 调用sess中的run方法来执行矩阵乘法op
result = sess.run(product)
print(result)
sess.close()
输出:
[[15]]