{"record":{"id":"04ac2c516a60efb8","repo":"keras-team/keras","slug":"axis-axis-is-out-of-bounds-for-input-shape-inpu","errorCode":null,"errorMessage":"Axis {axis} is out of bounds for input shape {input_shape}. Received: axis={self.axis}","messagePattern":"Axis (.+?) is out of bounds for input shape (.+?)\\. Received: axis=(.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/normalization/batch_normalization.py","lineNumber":327,"sourceCode":"            )\n\n        self.input_spec = InputSpec(\n            ndim=len(input_shape), axes={self.axis: input_shape[self.axis]}\n        )\n\n        reduction_axes = list(range(len(input_shape)))\n        del reduction_axes[self.axis]\n        self._reduction_axes = reduction_axes\n\n    def compute_output_shape(self, input_shape):\n        if isinstance(self.axis, int):\n            axes = [self.axis]\n        else:\n            axes = self.axis\n\n        for axis in axes:\n            if axis >= len(input_shape) or axis < -len(input_shape):\n                raise ValueError(\n                    f\"Axis {axis} is out of bounds for \"\n                    f\"input shape {input_shape}. \"\n                    f\"Received: axis={self.axis}\"\n                )\n        return input_shape\n\n    def call(self, inputs, training=None, mask=None):\n        # Check if the mask has one less dimension than the inputs.\n        if mask is not None:\n            if len(mask.shape) != len(inputs.shape) - 1:\n                # Raise a value error\n                raise ValueError(\n                    \"The mask provided should be one dimension less \"\n                    \"than the inputs. Received: \"\n                    f\"mask.shape={mask.shape}, inputs.shape={inputs.shape}\"\n                )\n\n        compute_dtype = backend.result_type(inputs.dtype, \"float32\")","sourceCodeStart":309,"sourceCodeEnd":345,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/normalization/batch_normalization.py#L309-L345","documentation":"Error \"Axis {axis} is out of bounds for input shape {input_shape}. Received: axis={self.axis}\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/layers/normalization/batch_normalization.py:327 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"}