In Deep Learning, we store our data in the form of Tensors.
Tensors can also be defined as a generalization of matrices to an arbitrary number of dimensions.
Scalars (0D Tensors)
A tensor that contains only one number is called a scalar, a scalar-tensor has 0 axes (ndim == 0). The number of axes of a tensor is also called it’s rank(张量的轴数也叫做它的秩).
a = 0
Vectors (1D tensors)
An array of numbers is called a vector, or 1D tensor. A 1D tensor is said to have exactly one axis.
array([15, 2, 7, 4])
Matrices (2D tensors)
A matrix has two axes (often referred to as rows and columns).
>>> x = np.array([[5, 78, 2, 34, 0], [6, 79, 3, 35, 1], [7, 80, 4, 36, 2]])
>>> x.ndim
2
3D Tensor
An image tensor is always 3D : One dimension for its height , one for its width and a third one for its color channel.
4D Tensor
A 4D Tensor is an array of 3D Tensors.
5D Tensor
A 5D Tensor is an array of 4D Tensors, like so:
|