keras-team/keras · error · ValueError
Invalid value for attribute `constraint`. Expected a callabl
Error message
Invalid value for attribute `constraint`. Expected a callable (such as a `keras.constraints.Constraint` instance) or `None`. Received: constraint={value} What it means
Error "Invalid value for attribute `constraint`. Expected a callable (such as a `keras.constraints.Constraint` instance) or `None`. Received: constraint={value}" thrown in keras-team/keras.
Source
Thrown at keras/src/backend/common/variables.py:392
@regularizer.setter
def regularizer(self, value):
if value is not None and not callable(value):
raise ValueError(
"Invalid value for attribute `regularizer`. Expected a "
"callable (such as a `keras.regularizers.Regularizer` "
f"instance) or `None`. Received: regularizer={value}"
)
self._regularizer = value
@property
def constraint(self):
return self._constraint
@constraint.setter
def constraint(self, value):
if value is not None and not callable(value):
raise ValueError(
"Invalid value for attribute `constraint`. Expected a "
"callable (such as a `keras.constraints.Constraint` instance) "
f"or `None`. Received: constraint={value}"
)
self._constraint = value
def __repr__(self):
value = None
if hasattr(self, "_value") and self._value is not None:
try:
value = backend.core.convert_to_numpy(self._value)
except:
# In some cases the conversion to numpy can fail.
pass
value_str = f", value={value}" if value is not None else ""
return (
f"<Variable path={self.path}, shape={self.shape}, "
f"dtype={self.dtype}{value_str}>"View on GitHub (pinned to 7a34a03db6)
When it happens
Trigger: Thrown at keras/src/backend/common/variables.py:392 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/10415b9f8689f8c9.
Report an issue: GitHub.