View source on GitHub
|
Tensor contraction of a and b along specified axes and outer product.
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 \(a_{ijk}\) and \(b_{lmn}\) represent two
tensors of order 3. Then, contract(a, b, [[0], [2]]) is the order 4 tensor
\(c_{jklm}\) whose entry
corresponding to the indices \((j,k,l,m)\) is given by:
\( c_{jklm} = \sum_i a_{ijk} b_{lmi} \).
In general, order(c) = order(a) + order(b) - 2*len(axes[0]).
For example | |
|---|---|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license. Last updated 2026-11-04 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-11-04 UTC."],[],[]]
|
View source on GitHub