{"record":{"id":"f6f78970d74c4aaf","repo":"keras-team/keras","slug":"cannot-do-batch-dot-on-inputs-with-shapes-x-shape","errorCode":null,"errorMessage":"Cannot do batch_dot on inputs with shapes {x_shape} and {y_shape} with axes={axes}. x.shape[{axes[0]}] != y.shape[{axes[1]}] ({d1} != {d2}).","messagePattern":"Cannot do batch_dot on inputs with shapes (.+?) and (.+?) with axes=(.+?)\\. x\\.shape\\[(.+?)\\] != y\\.shape\\[(.+?)\\] \\((.+?) != (.+?)\\)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/merging/dot.py","lineNumber":116,"sourceCode":"    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\n    orig_y_ndim = y_ndim\n\n    # if rank is 2, expand to 3.\n    if x_ndim == 2:\n        x = ops.expand_dims(x, 1)\n        a0 += 1\n        x_ndim += 1\n    if y_ndim == 2:\n        y = ops.expand_dims(y, 2)\n        y_ndim += 1\n","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/merging/dot.py#L98-L134","documentation":"Error \"Cannot do batch_dot on inputs with shapes {x_shape} and {y_shape} with axes={axes}. x.shape[{axes[0]}] != y.shape[{axes[1]}] ({d1} != {d2}).\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/layers/merging/dot.py:116 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"}