{"record":{"id":"c9f76a48e516b1b8","repo":"keras-team/keras","slug":"expected-t-name-to-have-shape-b-1-t-s-or","errorCode":null,"errorMessage":"Expected `{t_name}` to have shape (B, 1, T, S) or (B, N, T, S) with N={N} but got {t.shape}.","messagePattern":"Expected `(.+?)` to have shape \\(B, 1, T, S\\) or \\(B, N, T, S\\) with N=(.+?) but got (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/backend/jax/nn.py","lineNumber":1856,"sourceCode":"\n    # _dot_product_attention_xla\n    B, T, N, H = query.shape\n    G = N // K\n    query = jnp.reshape(query, (B, T, K, G, H))\n\n    def _reshape_to_grouped(t, t_name):\n        if t is not None:\n            while t.ndim < 4:\n                if t.ndim == 3 and t.shape[1] == N:\n                    t = jnp.expand_dims(t, axis=2)\n                else:\n                    t = jnp.expand_dims(t, axis=1)\n            tB, tN, tT, tS = t.shape\n            if tN == 1:\n                t = jnp.broadcast_to(t[:, :, None, :, :], (tB, tN, G, tT, tS))\n            else:\n                if tN != N:\n                    raise ValueError(\n                        f\"Expected `{t_name}` to have shape (B, 1, T, S) or \"\n                        f\"(B, N, T, S) with N={N} but got {t.shape}.\"\n                    )\n                t = jnp.reshape(t, (tB, K, G, tT, tS))\n        return t\n\n    bias = _reshape_to_grouped(bias, \"bias\")\n    mask = _reshape_to_grouped(mask, \"mask\")\n    vmapped_fn = jax.vmap(\n        _dot_product_attention_core,\n        in_axes=(3, None, None, 2, 2, None, None),\n        out_axes=3,\n    )\n    encoded = vmapped_fn(query, key, value, bias, mask, is_causal, scale)\n    return jnp.reshape(encoded, output_shape)\n\n\ndef unfold(input, kernel_size, dilation=1, padding=0, stride=1):","sourceCodeStart":1838,"sourceCodeEnd":1874,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/backend/jax/nn.py#L1838-L1874","documentation":"Error \"Expected `{t_name}` to have shape (B, 1, T, S) or (B, N, T, S) with N={N} but got {t.shape}.\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/backend/jax/nn.py:1856 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"}