张量 tensor

一段程序示例

>>> import tensorflow as tf
>>> a=tf.constant([1.0,2.0],name='a')
>>> b=tf.constant([2.0,3.0],name='b')
>>> result=tf.add(a,b,name='add')
>>> print result
Tensor("add:0", shape=(2,), dtype=float32)

Tensorflow计算的结果不是一个具体的数字,而是一个张量的结构

一个张量主要保存了三个属性:名字(name),维度(shape),类型(type)

名字name

node:src_output

node:节点的名字

src_output:当前张量来自节点的第几个输出

维度shape

shape=(2,)

一维数组,这个数组的长度为2

类型type

一般建议通过指定dtype来明确指出变量或者常量的类型

posted on 2017-05-15 19:10  juedaiyuer  阅读(182)  评论(0编辑  收藏  举报

导航