TensorFlow数据模型--张量

来源:互联网 发布:淘宝基础教程 编辑:程序博客网 时间:2024/06/07 04:49

1、张量(tensor)

>>> result=tf.add(a,b,name='addTwo')>>> print(result)Tensor("addTwo:0", shape=(2,), dtype=float32)
注:shape(2,)是一个一维数组,长度为2。

张量,有三个属性,分别为:名称addTwo,维度shape,类型type。
张量本身并没有存储具体的数值,需要会话session来计算。

2、tensor支持的类型

tensor,支持14种不同类型,分别为
实数(tf.float32, tf.float64),
整数(tf.int8, tf.int16, tf.int32,tf.int64, tf.unit8),
布尔型(tf.bool),
复数(tf.complex64, tf.complex128).