{"record":{"id":"1b111873338a6018","repo":"keras-team/keras","slug":"number-of-groups-self-groups-cannot-be-more-th","errorCode":null,"errorMessage":"Number of groups ({self.groups}) cannot be more than the number of channels ({dim}).","messagePattern":"Number of groups \\((.+?)\\) cannot be more than the number of channels \\((.+?)\\)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/normalization/group_normalization.py","lineNumber":117,"sourceCode":"        self.gamma_regularizer = regularizers.get(gamma_regularizer)\n        self.beta_constraint = constraints.get(beta_constraint)\n        self.gamma_constraint = constraints.get(gamma_constraint)\n\n    def build(self, input_shape):\n        dim = input_shape[self.axis]\n\n        if dim is None:\n            raise ValueError(\n                f\"Axis {self.axis} of input tensor should have a defined \"\n                \"dimension but the layer received an input with shape \"\n                f\"{input_shape}.\"\n            )\n\n        if self.groups == -1:\n            self.groups = dim\n\n        if dim < self.groups:\n            raise ValueError(\n                f\"Number of groups ({self.groups}) cannot be more than the \"\n                f\"number of channels ({dim}).\"\n            )\n\n        if dim % self.groups != 0:\n            raise ValueError(\n                f\"Number of groups ({self.groups}) must be a multiple \"\n                f\"of the number of channels ({dim}).\"\n            )\n\n        self.input_spec = InputSpec(\n            ndim=len(input_shape), axes={self.axis: dim}\n        )\n\n        if self.scale:\n            self.gamma = self.add_weight(\n                shape=(dim,),\n                name=\"gamma\",","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/normalization/group_normalization.py#L99-L135","documentation":"Raised in GroupNormalization.build() after resolving dim = input_shape[self.axis]: the requested groups exceeds the channel count on that axis. Each group needs at least one channel, so groups>dim is structurally impossible.","triggerScenarios":"Thrown at keras/src/layers/normalization/group_normalization.py:117 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reduce the groups argument so it is <= the number of channels on the normalization axis","Set groups=-1 to have the layer automatically use the full channel count as the number of groups","Verify the axis argument points at the intended channel axis (e.g. -1 for channels-last, 1 for channels-first)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}