4.什么是tensor(上)

import tensorflow as tf

const = tf.constant(3)
print(const)  # Tensor("Const:0", shape=(), dtype=int32)

a = 3
print(a)  # 3

# 可以看到如果直接打印const是不会输出3这个结果的,tensor不具备计算出值的能力,必须创建会话

sess = tf.Session()
print(sess.run(const))  # 3

  

猜你喜欢

转载自www.cnblogs.com/traditional/p/9339211.html
今日推荐