keras-team/keras · error · ValueError

Invalid value for attribute `regularizer`. Expected a callab

Error message

Invalid value for attribute `regularizer`. Expected a callable (such as a `keras.regularizers.Regularizer` instance) or `None`. Received: regularizer={value}

What it means

Error "Invalid value for attribute `regularizer`. Expected a callable (such as a `keras.regularizers.Regularizer` instance) or `None`. Received: regularizer={value}" thrown in keras-team/keras.

Source

Thrown at keras/src/backend/common/variables.py:378

        return self._overwrite_with_gradient

    @overwrite_with_gradient.setter
    def overwrite_with_gradient(self, value):
        if not isinstance(value, bool):
            raise TypeError(
                "`overwrite_with_gradient` must be a boolean. "
                f"Received: {value}"
            )
        self._overwrite_with_gradient = value

    @property
    def regularizer(self):
        return self._regularizer

    @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}"
            )

View on GitHub (pinned to 7a34a03db6)

When it happens

Trigger: Thrown at keras/src/backend/common/variables.py:378 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/7d41025e05eba012. Report an issue: GitHub.