How is tensordot calculated?

Numpy tensordot() is used to calculate the tensor dot product of two given tensors.

If we have given two tensors a and b, and two arrays like objects which denote axes, let say a_axes and b_axes.

The tensordot() function sum the product of a’s elements and b’s elements over the axes specified by a_axes and b_axes.

These a_axes and b_axes can be a scaler too, let say N. In this case, the last N dimension of the given tensors is summed over.

Numpy tensordot()

The tensordot() function calculates the tensor dot product along specified axes.

Given two tensors, a and b, and an array_like object containing two array_like objects, (a_axes, b_axes), sum the products of a’s and b’s elements (components) over the axes specified by a_axes and b_axes.

The third argument can be a single non-negative integer_like scalar, N; if it is such, then the last N dimensions of a and the first N dimensions of b are summed over.

Syntax

``````numpy.tensordot(tensor1, tensor2, axes)
``````

#python #programming #numpy

28.10 GEEK