{"record":{"id":"82fba81ccff195a1","repo":"keras-team/keras","slug":"the-mask-provided-should-be-one-dimension-less-tha","errorCode":null,"errorMessage":"The mask provided should be one dimension less than the inputs. Received: mask.shape={mask.shape}, inputs.shape={inputs.shape}","messagePattern":"The mask provided should be one dimension less than the inputs\\. Received: mask\\.shape=(.+?), inputs\\.shape=(.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/normalization/batch_normalization.py","lineNumber":339,"sourceCode":"            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\")\n        # BN is prone to overflow with float16/bfloat16 inputs, so we upcast to\n        # float32 for the subsequent computations.\n        inputs = ops.cast(inputs, compute_dtype)\n\n        moving_mean = ops.cast(self.moving_mean, inputs.dtype)\n        moving_variance = ops.cast(self.moving_variance, inputs.dtype)\n\n        if self.scale:\n            gamma = ops.cast(self.gamma, inputs.dtype)\n        else:\n            gamma = None\n","sourceCodeStart":321,"sourceCodeEnd":357,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/normalization/batch_normalization.py#L321-L357","documentation":"Error \"The mask provided should be one dimension less than the inputs. Received: mask.shape={mask.shape}, inputs.shape={inputs.shape}\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/layers/normalization/batch_normalization.py:339 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"}