keras-team/keras · error · ValueError
Number of groups ({self.groups}) cannot be more than the num
Error message
Number of groups ({self.groups}) cannot be more than the number of channels ({dim}). What it means
Error "Number of groups ({self.groups}) cannot be more than the number of channels ({dim})." thrown in keras-team/keras.
Source
Thrown at keras/src/layers/normalization/group_normalization.py:117
self.gamma_regularizer = regularizers.get(gamma_regularizer)
self.beta_constraint = constraints.get(beta_constraint)
self.gamma_constraint = constraints.get(gamma_constraint)
def build(self, input_shape):
dim = input_shape[self.axis]
if dim is None:
raise ValueError(
f"Axis {self.axis} of input tensor should have a defined "
"dimension but the layer received an input with shape "
f"{input_shape}."
)
if self.groups == -1:
self.groups = dim
if dim < self.groups:
raise ValueError(
f"Number of groups ({self.groups}) cannot be more than the "
f"number of channels ({dim})."
)
if dim % self.groups != 0:
raise ValueError(
f"Number of groups ({self.groups}) must be a multiple "
f"of the number of channels ({dim})."
)
self.input_spec = InputSpec(
ndim=len(input_shape), axes={self.axis: dim}
)
if self.scale:
self.gamma = self.add_weight(
shape=(dim,),
name="gamma",View on GitHub (pinned to 7a34a03db6)
When it happens
Trigger: Thrown at keras/src/layers/normalization/group_normalization.py:117 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25).
Data as JSON: /api/errors/1b111873338a6018.
Report an issue: GitHub.