https://tensorflow.google.cn/guide/tensor
Introduction to Tensors
Tensorsare multi-dimensional arrays with a uniform type (called adtype).tf.dtypesincluded all supported dtypes.
If you're familiar withNumPy, tensors are (kind of) likenp.arrays.All tensors are immutableandonly create a new one, just like Python numbers and strings: you can never update the contents of a tensor.
About shapes
Tensors have shapes. Some vocabulary:
Shape: The length (number of elements) of each of the axes of a tensor.Rank: Number of tensor axes:- A scalar has rank 0,
- a vector has rank 1,
- a matrix is rank 2.
Axis or Dimension: A particular dimension of a tensor.Size: The total number of items in the tensor, the product of the shape vector's elements.
Note: Although you may see reference to a "tensor of two dimensions", a rank-2 tensor does not usually describe a 2D space.
Tensors and tf.TensorShape objects have convenient properties for accessing these: