keras-team/keras · error · ValueError
Number of groups ({self.groups}) must be a multiple of the n
Error message
Number of groups ({self.groups}) must be a multiple of the number of channels ({dim}). What it means
Error "Number of groups ({self.groups}) must be a multiple of the number of channels ({dim})." thrown in keras-team/keras.
Source
Thrown at keras/src/layers/normalization/group_normalization.py:123
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",
initializer=self.gamma_initializer,
regularizer=self.gamma_regularizer,
constraint=self.gamma_constraint,
autocast=False,
)
else:View on GitHub (pinned to 7a34a03db6)
When it happens
Trigger: Thrown at keras/src/layers/normalization/group_normalization.py:123 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/f4bf442f39cc87be.
Report an issue: GitHub.