@@ -1150,19 +1150,29 @@ def tensordot(a, b, axes=2):
1150
1150
----------
1151
1151
a, b : array_like, len(shape) >= 1
1152
1152
Tensors to "dot".
1153
- axes : variable type
1154
- * integer_like scalar
1155
- Number of axes to sum over (applies to both arrays); or
1156
- * (2,) array_like, both elements array_like of the same length
1157
- List of axes to be summed over, first sequence applying to `a`,
1158
- second to `b`.
1153
+ axes : {integer_like, array_like}
1154
+ * integer_like
1155
+ If an int N, sum over the last N axes of `a` and the first N axes
1156
+ of `b` in order. The sizes of the corresponding axes must match.
1157
+ * (2,) array_like
1158
+ Or, a list of axes to be summed over, first sequence applying to `a`,
1159
+ second to `b`. Both elements array_like must be of the same length.
1159
1160
1160
1161
See Also
1161
1162
--------
1162
1163
dot, einsum<
8000
/span>
1163
1164
1164
1165
Notes
1165
1166
-----
1167
+ Three common use cases are:
1168
+ ``axes = 0`` : tensor product $a\otimes b$
1169
+ ``axes = 1`` : tensor dot product $a\cdot b$
1170
+ ``axes = 2`` : (default) tensor double contraction $a:b$
1171
+
1172
+ When `axes` is integer_like, the sequence for evaluation will be: first
1173
+ the -Nth axis in `a` and 0th axis in `b`, and the -1th axis in `a` and
1174
+ Nth axis in `b` last.
1175
+
1166
1176
When there is more than one axis to sum over - and they are not the last
1167
1177
(first) axes of `a` (`b`) - the argument `axes` should consist of
1168
1178
two sequences of the same length, with the first axis to sum over given
@@ -1211,7 +1221,7 @@ def tensordot(a, b, axes=2):
1211
1221
array([[a, b],
1212
1222
[c, d]], dtype=object)
1213
1223
1214
- >>> np.tensordot(a, A) # third argument default is 2
1224
+ >>> np.tensordot(a, A) # third argument default is 2 for double-contraction
1215
1225
array([abbcccdddd, aaaaabbbbbbcccccccdddddddd], dtype=object)
1216
1226
1217
1227
>>> np.tensordot(a, A, 1)
@@ -1220,7 +1230,7 @@ def tensordot(a, b, axes=2):
1220
1230
[[aaaaacccccc, bbbbbdddddd],
1221
1231
[aaaaaaacccccccc, bbbbbbbdddddddd]]], dtype=object)
1222
1232
1223
- >>> np.tensordot(a, A, 0) # "Left for reader" (result too long to incl.)
1233
+ >>> np.tensordot(a, A, 0) # tensor product (result too long to incl.)
1224
1234
array([[[[[a, b],
1225
1235
[c, d]],
1226
1236
...
0 commit comments