Image Generated by Author Using Stable Diffusion (license)

Tensordot — Multidimensional Dot Product — Explained

Dennis Alexander Morozov
Analytics Vidhya
Published in
15 min readOct 15, 2021

--

Tensordot from Scalars to Multidimensional Tensors

The multidimensional operator, axes destroyer, and dimensional transformer, tensordot have earned its rightful place in the coliseum of super useful multi-dimensional matrix operators. Tensordot is a powerful tool for tensors (multi-dimensional matrices), but it can also be a bit elusive and seem slightly magical. The difficulty in gaining a robust intuition for tensordot is mostly due to the fact that if you need a tensordot operation, your mind is likely already dazed with keeping track of all the dimensions of a tensor. To get a full grasp of tensordots, it helps to start from simple matrices and then slowly build an intuition all the way up to multidimensional operations.

Here are a few reasons to master tensordot:

  1. Tensordot is a super useful tool in tensor operations applicable in optimization, engineering, machine learning… or anywhere else you need to perform multidimensional operations.
  2. You can speed up your code by using tensordot instead of nested loops for multidimensional dot-products.
  3. It will help you build an intuition for multi-dimensional operations in general, and give you experience with tensors.
  4. Once you fully understand…

--

--

Dennis Alexander Morozov
Analytics Vidhya

Data Scientist, Machine Learning Engineer, Life Long Student