张量是一个类型化的N维数组(tf.Tensor),由三部分组成:名字,形状,数据类型。
张量的阶:
张量的数据类型:
demo.py(张量的属性,shape形状,name名字,op操作):
import tensorflow as tf
import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='2' # 设置警告级别
a = tf.constant(5.0)
print(a) # Tensor("Const:0", shape=(), dtype=float32)
# 会话
with tf.Session() as sess:
# 张量的属性
print(a.shape) # () ()表示标量,(5,)表示长度为5的一维数组,(5,6)表示二维,(5,6,7)表示三维
print(a.name) # Const:0 表示Const操作符的第一个输出
print(a.op) # 张量的操作名
'''
name