keras-team/keras · error · ValueError
Axis {self.axis} of input tensor should have a defined dimen
Error message
Axis {self.axis} of input tensor should have a defined dimension but the layer received an input with shape {input_shape}. What it means
Error "Axis {self.axis} of input tensor should have a defined dimension but the layer received an input with shape {input_shape}." thrown in keras-team/keras.
Source
Thrown at keras/src/layers/normalization/group_normalization.py:107
self.supports_masking = True
self.autocast = False
self.groups = groups
self.axis = axis
self.epsilon = epsilon
self.center = center
self.scale = scale
self.beta_initializer = initializers.get(beta_initializer)
self.gamma_initializer = initializers.get(gamma_initializer)
self.beta_regularizer = regularizers.get(beta_regularizer)
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})."View on GitHub (pinned to 7a34a03db6)
When it happens
Trigger: Thrown at keras/src/layers/normalization/group_normalization.py:107 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/470b73eef408242a.
Report an issue: GitHub.