keras-team/keras · error · ValueError

Received an invalid value for `threshold`, expected a non-ne

Error message

Received an invalid value for `threshold`, expected a non-negative float or None. Received: threshold={threshold}

What it means

Error "Received an invalid value for `threshold`, expected a non-negative float or None. Received: threshold={threshold}" thrown in keras-team/keras.

Source

Thrown at keras/src/layers/core/ternary_dense.py:135

        kernel_regularizer=None,
        bias_regularizer=None,
        activity_regularizer=None,
        kernel_constraint=None,
        bias_constraint=None,
        **kwargs,
    ):
        if not isinstance(units, int) or units <= 0:
            raise ValueError(
                "Received an invalid value for `units`, expected a positive "
                f"integer. Received: units={units}"
            )
        if threshold is not None and not isinstance(threshold, (int, float)):
            raise ValueError(
                "Received an invalid value for `threshold`, expected a float "
                f"or None. Received: threshold={threshold}"
            )
        if threshold is not None and threshold < 0:
            raise ValueError(
                "Received an invalid value for `threshold`, expected a "
                "non-negative float or None. "
                f"Received: threshold={threshold}"
            )

        super().__init__(activity_regularizer=activity_regularizer, **kwargs)
        self.units = units
        self.threshold = threshold
        self.activation = activations.get(activation)
        self.use_bias = use_bias
        self.kernel_initializer = initializers.get(kernel_initializer)
        self.bias_initializer = initializers.get(bias_initializer)
        self.kernel_regularizer = regularizers.get(kernel_regularizer)
        self.bias_regularizer = regularizers.get(bias_regularizer)
        self.kernel_constraint = constraints.get(kernel_constraint)
        self.bias_constraint = constraints.get(bias_constraint)
        self.input_spec = InputSpec(min_ndim=2)
        self.supports_masking = True

View on GitHub (pinned to 7a34a03db6)

When it happens

Trigger: Thrown at keras/src/layers/core/ternary_dense.py:135 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/a88426bfb0b01105. Report an issue: GitHub.