{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "DefList",
          "__tag": 4033,
          "children": [
            {
              "__type": "DefListItem",
              "__tag": 4037,
              "dt": {
                "__type": "Paragraph",
                "__tag": 4045,
                "children": [
                  {
                    "__type": "Text",
                    "__tag": 4046,
                    "value": "Three common use cases are:"
                  }
                ]
              },
              "dd": [
                {
                  "__type": "BulletList",
                  "__tag": 4053,
                  "ordered": false,
                  "start": 1,
                  "children": [
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "InlineCode",
                              "__tag": 4051,
                              "value": "axes = 0"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "tensor product "
                            },
                            {
                              "__type": "InlineMath",
                              "__tag": 4057,
                              "value": "a\\otimes b"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "InlineCode",
                              "__tag": 4051,
                              "value": "axes = 1"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "tensor dot product "
                            },
                            {
                              "__type": "InlineMath",
                              "__tag": 4057,
                              "value": "a\\cdot b"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "InlineCode",
                              "__tag": 4051,
                              "value": "axes = 2"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "(default) tensor double contraction "
                            },
                            {
                              "__type": "InlineMath",
                              "__tag": 4057,
                              "value": "a:b"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "When "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "axes"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is integer_like, the sequence of axes for evaluation will be: from the -Nth axis to the -1th axis in "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "a"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", and from the 0th axis to (N-1)th axis in "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "b"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". For example, "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "axes = 2"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is the equal to "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "axes = [[-2, -1], [0, 1]]"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". When N-1 is smaller than 0, or when -N is larger than -1, the element of "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "a"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "b"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " are defined as the "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "axes"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "When there is more than one axis to sum over - and they are not the last (first) axes of "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "a"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " ("
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "b"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ") - the argument "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "axes"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " should consist of two sequences of the same length, with the first axis to sum over given first in both sequences, the second axis second, and so forth. The calculation can be referred to "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "numpy.einsum"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The shape of the result consists of the non-contracted axes of the first tensor, followed by the non-contracted axes of the second."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Raises": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Yields": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Methods": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Returns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "output",
              "annotation": "ndarray",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The tensor dot product of the input."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Compute tensor dot product along specified axes."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Receives": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warnings": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Attributes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "a, b",
              "annotation": "array_like",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Tensors to \"dot\"."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "axes",
              "annotation": "int or (2,) array_like",
              "desc": [
                {
                  "__type": "BulletList",
                  "__tag": 4053,
                  "ordered": false,
                  "start": 1,
                  "children": [
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "integer_like   If an int N, sum over the last N axes of "
                            },
                            {
                              "__type": "ParamRef",
                              "__tag": 4071,
                              "name": "a"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": " and the first N axes   of "
                            },
                            {
                              "__type": "ParamRef",
                              "__tag": 4071,
                              "name": "b"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": " in order. The sizes of the corresponding axes must match."
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "(2,) array_like   Or, a list of axes to be summed over, first sequence applying to "
                            },
                            {
                              "__type": "ParamRef",
                              "__tag": 4071,
                              "name": "a"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": ",   second to "
                            },
                            {
                              "__type": "ParamRef",
                              "__tag": 4071,
                              "name": "b"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": ". Both elements array_like must be of the same length."
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Given two tensors, "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "a"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "b"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", and an array_like object containing two array_like objects, "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "(a_axes, b_axes)"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", sum the products of "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "a"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "'s and "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "b"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "'s elements (components) over the axes specified by "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "a_axes"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "b_axes"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". The third argument can be a single non-negative integer_like scalar, "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "N"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "; if it is such, then the last "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "N"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " dimensions of "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "a"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and the first "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "N"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " dimensions of "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "b"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " are summed over."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Other Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    }
  },
  "_ordered_sections": [
    "Summary",
    "Extended Summary",
    "Parameters",
    "Attributes",
    "Methods",
    "Returns",
    "Yields",
    "Receives",
    "Other Parameters",
    "Raises",
    "Warns",
    "Warnings",
    "Notes"
  ],
  "item_file": "/dev/numpy/build-install/usr/lib/python3.14/site-packages/numpy/_core/numeric.py",
  "item_line": 1001,
  "item_type": "_ArrayFunctionDispatcher",
  "aliases": [
    "numpy.tensordot"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "An example on integer_like:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "a_0 = np.array([[1, 2], [3, 4]])\nb_0 = np.array([[5, 6], [7, 8]])\nc_0 = np.tensordot(a_0, b_0, axes=0)\nc_0.shape\n",
        "execution_status": "success",
        "out": "(2, 2, 2, 2)\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "c_0\n",
        "execution_status": "failure",
        "out": "array([[[[ 5,  6],\n         [ 7,  8]],\n\n        [[10, 12],\n         [14, 16]]],\n\n\n       [[[15, 18],\n         [21, 24]],\n\n        [[20, 24],\n         [28, 32]]]])\n"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nAn example on array_like:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "a = np.arange(60.).reshape(3,4,5)\nb = np.arange(24.).reshape(4,3,2)\nc = np.tensordot(a,b, axes=([1,0],[0,1]))\nc.shape\nc\n",
        "execution_status": "success",
        "out": "array([[4400., 4730.],\n       [4532., 4874.],\n       [4664., 5018.],\n       [4796., 5162.],\n       [4928., 5306.]])\n"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nA slower but equivalent way of computing the same...\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "d = np.zeros((5,2))\nfor i in range(5):\n  for j in range(2):\n    for k in range(3):\n      for n in range(4):\n        d[i,j] += a[k,n,i] * b[n,k,j]\nc == d\n",
        "execution_status": "success",
        "out": "array([[ True,  True],\n       [ True,  True],\n       [ True,  True],\n       [ True,  True],\n       [ True,  True]])\n"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nAn extended example taking advantage of the overloading of + and \\*:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "a = np.array(range(1, 9)).reshape((2, 2, 2))\nA = np.array(('a', 'b', 'c', 'd'), dtype=object)\nA = A.reshape((2, 2))\n",
        "execution_status": "success",
        "out": ""
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "a; A\n",
        "execution_status": "failure",
        "out": "array([[[1, 2],\n        [3, 4]],\n\n       [[5, 6],\n        [7, 8]]])\narray([['a', 'b'],\n       ['c', 'd']], dtype=object)\n"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "np.tensordot(a, A) # third argument default is 2 for double-contraction\n",
        "execution_status": "success",
        "out": "array(['abbcccdddd', 'aaaaabbbbbbcccccccdddddddd'], dtype=object)\n"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "np.tensordot(a, A, 1)\n",
        "execution_status": "failure",
        "out": "array([[['acc', 'bdd'],\n        ['aaacccc', 'bbbdddd']],\n\n       [['aaaaacccccc', 'bbbbbdddddd'],\n        ['aaaaaaacccccccc', 'bbbbbbbdddddddd']]], dtype=object)\n"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "np.tensordot(a, A, 0) # tensor product (result too long to incl.)\n",
        "execution_status": "failure",
        "out": "array([[[[['a', 'b'],\n          ['c', 'd']],\n\n         [['aa', 'bb'],\n          ['cc', 'dd']]],\n\n\n        [[['aaa', 'bbb'],\n          ['ccc', 'ddd']],\n\n         [['aaaa', 'bbbb'],\n          ['cccc', 'dddd']]]],\n\n\n\n       [[[['aaaaa', 'bbbbb'],\n          ['ccccc', 'ddddd']],\n\n         [['aaaaaa', 'bbbbbb'],\n          ['cccccc', 'dddddd']]],\n\n\n        [[['aaaaaaa', 'bbbbbbb'],\n          ['ccccccc', 'ddddddd']],\n\n         [['aaaaaaaa', 'bbbbbbbb'],\n          ['cccccccc', 'dddddddd']]]]], dtype=object)\n"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "np.tensordot(a, A, (0, 1))\n",
        "execution_status": "failure",
        "out": "array([[['abbbbb', 'cddddd'],\n        ['aabbbbbb', 'ccdddddd']],\n\n       [['aaabbbbbbb', 'cccddddddd'],\n        ['aaaabbbbbbbb', 'ccccdddddddd']]], dtype=object)\n"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "np.tensordot(a, A, (2, 1))\n",
        "execution_status": "failure",
        "out": "array([[['abb', 'cdd'],\n        ['aaabbbb', 'cccdddd']],\n\n       [['aaaaabbbbbb', 'cccccdddddd'],\n        ['aaaaaaabbbbbbbb', 'cccccccdddddddd']]], dtype=object)\n"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "np.tensordot(a, A, ((0, 1), (0, 1)))\n",
        "execution_status": "success",
        "out": "array(['abbbcccccddddddd', 'aabbbbccccccdddddddd'], dtype=object)\n"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "np.tensordot(a, A, ((2, 1), (1, 0)))\n",
        "execution_status": "success",
        "out": "array(['acccbbdddd', 'aaaaacccccccbbbbbbdddddddd'], dtype=object)\n"
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "dot",
        "reference": {
          "__type": "LocalRef",
          "__tag": 4022,
          "kind": "module",
          "path": "numpy:dot"
        },
        "kind": "module"
      },
      "descriptions": [],
      "type": null
    },
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "einsum",
        "reference": {
          "__type": "LocalRef",
          "__tag": 4022,
          "kind": "module",
          "path": "numpy:einsum"
        },
        "kind": "module"
      },
      "descriptions": [],
      "type": null
    }
  ],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "a",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "b",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "axes",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "2"
      }
    ],
    "return_annotation": {
      "__type": "Empty",
      "__tag": 4031
    },
    "target_name": "tensordot"
  },
  "references": null,
  "qa": "numpy:tensordot",
  "arbitrary": [],
  "local_refs": [
    "a",
    "axes",
    "b",
    "output"
  ]
}