keras-team/keras · error · ValueError
Invalid value received for argument `rate`. Expected a float
Error message
Invalid value received for argument `rate`. Expected a float value between 0 and 1. Received: rate={rate} What it means
Error "Invalid value received for argument `rate`. Expected a float value between 0 and 1. Received: rate={rate}" thrown in keras-team/keras.
Source
Thrown at keras/src/layers/regularization/alpha_dropout.py:38
noise_shape: 1D integer tensor representing the shape of the
binary alpha dropout mask that will be multiplied with the input.
For instance, if your inputs have shape
`(batch_size, timesteps, features)` and
you want the alpha dropout mask to be the same for all timesteps,
you can use `noise_shape=(batch_size, 1, features)`.
seed: A Python integer to use as random seed.
Call arguments:
inputs: Input tensor (of any rank).
training: Python boolean indicating whether the layer should behave in
training mode (adding alpha dropout) or in inference mode
(doing nothing).
"""
def __init__(self, rate, noise_shape=None, seed=None, **kwargs):
super().__init__(**kwargs)
if not 0 <= rate <= 1:
raise ValueError(
f"Invalid value received for argument "
"`rate`. Expected a float value between 0 and 1. "
f"Received: rate={rate}"
)
self.rate = rate
self.seed = seed
self.noise_shape = noise_shape
if rate > 0:
self.seed_generator = backend.random.SeedGenerator(seed)
self.supports_masking = True
self._build_at_init()
def call(self, inputs, training=False):
if training and self.rate > 0:
noise_shape = self._get_concrete_noise_shape(
inputs, self.noise_shape
)View on GitHub (pinned to 7a34a03db6)
When it happens
Trigger: Thrown at keras/src/layers/regularization/alpha_dropout.py:38 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/28e07447cbe1362c.
Report an issue: GitHub.