{"record":{"id":"384363e0fb5aeb01","repo":"keras-team/keras","slug":"cannot-perform-batch-dot-over-axis-0-if-your-inpu","errorCode":null,"errorMessage":"Cannot perform batch_dot over axis 0. If your inputs are not batched, add a dummy batch dimension to your inputs using keras.ops.expand_dims(x, 0)","messagePattern":"Cannot perform batch_dot over axis 0\\. If your inputs are not batched, add a dummy batch dimension to your inputs using keras\\.ops\\.expand_dims\\(x, 0\\)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/merging/dot.py","lineNumber":105,"sourceCode":"    if any(isinstance(a, (list, tuple)) for a in axes):\n        raise ValueError(\n            f\"Multiple target dimensions are not supported. \"\n            f\"Expected: None, int, (int, int), \"\n            f\"Provided: {axes} \"\n        )\n\n    # if tuple, convert to list.\n    axes = list(axes)\n\n    # convert negative indices.\n    if axes[0] < 0:\n        axes[0] += x_ndim\n    if axes[1] < 0:\n        axes[1] += y_ndim\n\n    # sanity checks\n    if 0 in axes:\n        raise ValueError(\n            \"Cannot perform batch_dot over axis 0. \"\n            \"If your inputs are not batched, \"\n            \"add a dummy batch dimension to your \"\n            \"inputs using keras.ops.expand_dims(x, 0)\"\n        )\n    a0, a1 = axes\n    d1 = x_shape[a0]\n    d2 = y_shape[a1]\n\n    if d1 is not None and d2 is not None and d1 != d2:\n        raise ValueError(\n            f\"Cannot do batch_dot on inputs with shapes \"\n            f\"{x_shape} and {y_shape} with axes={axes}. \"\n            f\"x.shape[{axes[0]}] != y.shape[{axes[1]}] ({d1} != {d2}).\"\n        )\n\n    # backup ndims. Need them later.\n    orig_x_ndim = x_ndim","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/merging/dot.py#L87-L123","documentation":"Error \"Cannot perform batch_dot over axis 0. If your inputs are not batched, add a dummy batch dimension to your inputs using keras.ops.expand_dims(x, 0)\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/layers/merging/dot.py:105 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}