From the name of TensorFlow can be seen that tensor (tensor) is a very heavy concept. All the data in the TensorFlow program is represented by the tensor form. From a functional point of view, the tensor can be understood as a multidimensional array. The 0-order tensor indicates a scalar (scalar) is a number, the first-order tensor is a vector, that is, a one-dimensional array; n-order tensor can be interpreted as an n-dimensional array. But the implementation of tensor is not directly in the form of an array, it is only a reference to the result of the operation in TensorFlow. The number is not saved in the tensor, and it holds the computational process of how to get these numbers.
The following code, without the result of addition, will get a reference to the result.
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)
The output is: Tensor ("add:0", shape= (2,), Dtype=float32).
From the above code can be seen in the TensorFlow tensor and numpy in the array of different, tensorflow calculation of the elder sister results is not a specific number, but a Zhang Liang structure. As you can see from the above code, a tensor mainly holds three properties: Name, Dimension (shape), and type.
The first property name of the tensor is not only a unique identifier for a tensor, it also shows how the tensor is computed. The calculation of TensorFlow can be established by calculating the model of the graph, and each node on the graph represents a calculation, and the result of the calculation is stored in the tensor. So the tensor is corresponding to the calculated result represented by the node on the calculation graph. The name of such tensor can be given in the form of "Node:str_output". Where node is the name of nodes, Str_output represents the current tensor from the first few outputs of the node. For example, the "add:0" above the code shows that result this tensor is the first outcome of the compute node "add" output (numbering starts from zero).
The second property of the tensor is the dimension (shape) of the tensor. This property describes the dimension information for a tensor. The third property of the tensor is type, and each tensor has a unique type. TensorFlow will type-check all the tensor that participates in the operation, and will complain when the type mismatch is found.