{"record":{"id":"1d6f9c7ef75a6339","repo":"keras-team/keras","slug":"axis-size-must-be-divisible-by-2-received-x-shap-1d6f9c","errorCode":null,"errorMessage":"axis size must be divisible by 2. Received: x.shape={x.shape} with axis={axis}","messagePattern":"axis size must be divisible by 2\\. Received: x\\.shape=(.+?) with axis=(.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/backend/numpy/ops/nn.py","lineNumber":181,"sourceCode":"            * (scipy.special.erf(x / sqrt_2) + 1).astype(x.dtype)\n            / np.array(2, x.dtype)\n        )\n\n\ndef celu(x, alpha=1.0):\n    x = convert_to_tensor(x)\n    alpha = np.array(alpha, x.dtype)\n    return np.maximum(x, np.array(0.0, dtype=x.dtype)) + alpha * np.expm1(\n        np.minimum(x, np.array(0.0, dtype=x.dtype)) / alpha\n    )\n\n\ndef glu(x, axis=-1):\n    x = convert_to_tensor(x)\n    dtype = x.dtype\n    canonicalize_axis(axis, len(x.shape))\n    if x.shape[axis] % 2 != 0:\n        raise ValueError(\n            \"axis size must be divisible by 2. \"\n            f\"Received: x.shape={x.shape} with axis={axis}\"\n        )\n    x1, x2 = np.split(x, 2, axis)\n    return (x1 * sigmoid(x2)).astype(dtype)\n\n\ndef hard_tanh(x):\n    x = convert_to_tensor(x)\n    min_val = np.asarray(-1.0, x.dtype)\n    max_val = np.asarray(1.0, x.dtype)\n    return np.array(np.clip(x, min_val, max_val), dtype=x.dtype)\n\n\ndef hard_shrink(x, threshold=0.5):\n    x = convert_to_tensor(x)\n    threshold = np.asarray(threshold, x.dtype)\n    return np.array(","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/backend/numpy/ops/nn.py#L163-L199","documentation":"Error \"axis size must be divisible by 2. Received: x.shape={x.shape} with axis={axis}\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/backend/numpy/ops/nn.py:181 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"}