TF0001、创建和启动会话

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]]
发布了23 篇原创文章 · 获赞 1 · 访问量 3358

猜你喜欢

转载自blog.csdn.net/ABCDABCD321123/article/details/104290653