Tensor contraction of a and b along specified axes and outer product.
View aliases
Main aliases
Compat aliases for migrationSee Migration guide for more details.
tf.tensordot(
a, b, axes, name=None
)
Tensordot (also known as tensor contraction) sums the product of elements
from a
and b
over the indices specified by axes
.
This operation corresponds to numpy.tensordot(a, b, axes)
.
Example 1: When a
and b
are matrices (order 2), the case axes=1
is equivalent to matrix multiplication.
Example 2: When a
and b
are matrices (order 2), the case
axes = [[1], [0]]
is equivalent to matrix multiplication.
Example 3: When a
and b
are matrices (order 2), the case axes=0
gives
the outer product, a tensor of order 4.
Example 4: Suppose that and represent two
tensors of order 3. Then, contract(a, b, [[0], [2]])
is the order 4 tensor
whose entry
corresponding to the indices is given by:
.
In general, order(c) = order(a) + order(b) - 2*len(axes[0])
.
Returns | |
---|---|
A Tensor with the same type as a .
|