DEV Community

Cover image for What is a Tensor?
Rohan Yadav
Rohan Yadav

Posted on • Edited on

What is a Tensor?

Tensor is one of the most basic concepts to master in Machine & Deep Learning.

Definition

  • An nth rank tensor in m-dimensional space is a mathematical object that has n indices and mn components and obeys certain transformation rules.1

Tensors are invariant under a change of coordinates, and have components that change in a special, predictable way if there is a change in coordinates. The tensors in three-dimensional Euclidean space are called Cartesian tensors.

Tensors are identified by 3 parameters -

  • Rank: It represents the number of dimensions of the tensor.
  • Shape: Number of components in each of the dimensions represent shape of the tensor. For Example, for a 2 dimensional tensor, if it has 2 components in first index, and 3 components in the second index, then its shape would be (2,3).
  • Type: It represents the type of data that the tensor contains.

Popular Terminology

  • Scalars Tensors with rank = 0, are known as scalars or Rank-0 tensors.
  • Vectors Tensors with rank = 1, are known as scalars or Rank-1 tensors.
  • Matrices Tensors with rank = 2, are known as scalars or Rank-2 tensors.
  • Three-Dimensional Arrays Tensors with rank = 3, are known as scalars or Rank-3 tensors.

Examples

Footnotes

Top comments (0)