Examples of Tensor visualization#
We can use the above Rubik’s Cube (picture source) to intuitively understand Tensor:
First of all, we assume that this Rubik’s Cube is “solid and homogeneous” and is a Tensor that exists in the real world;
The type of each element in this Tensor (
dtype
) is the same (square shape, plus the same workmanship);And this is a structure with a dimension (
ndim
) of \(3\), and a shape (shape
) of \((3, 3, 3)\);Correspondingly, the total number of elements of the Tensor (
size
) is \(3*3*3=27\).
If you represent a value for each color, and the value of each magic square can be represented by the sum of its color values (the middle block is zero at this time), then different magic squares have their own values. It’s as if each element in Tensor can have its own value. In fact, in addition to the Rubik’s Cube, there are many things that can be abstracted into a Tensor data structure, which means that MegEngine can be used for related calculations.