{"record":{"id":"da83a0665f133a71","repo":"keras-team/keras","slug":"axis-size-must-be-divisible-by-2-received-x-shap-da83a0","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/tensorflow/nn.py","lineNumber":145,"sourceCode":"    return tf.nn.selu(x)\n\n\ndef gelu(x, approximate=True):\n    x = convert_to_tensor(x)\n    return tf.nn.gelu(x, approximate=approximate)\n\n\ndef celu(x, alpha=1.0):\n    return tf.maximum(x, 0.0) + alpha * tf.math.expm1(\n        tf.minimum(x, 0.0) / alpha\n    )\n\n\ndef glu(x, axis=-1):\n    x = convert_to_tensor(x)\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 = tf.split(x, num_or_size_splits=2, axis=axis)\n    return x1 * tf.sigmoid(x2)\n\n\ndef hard_tanh(x):\n    return tf.clip_by_value(x, clip_value_min=-1.0, clip_value_max=1.0)\n\n\ndef hard_shrink(x, threshold=0.5):\n    return tf.where(tf.abs(x) > threshold, x, tf.zeros_like(x))\n\n\ndef threshold(x, threshold, default_value):\n    return tf.where(x > threshold, x, default_value)\n","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/backend/tensorflow/nn.py#L127-L163","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/tensorflow/nn.py:145 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"}