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/dropout.py:44
rate: Float between 0 and 1. Fraction of the input units to drop.
noise_shape: 1D integer tensor representing the shape of the
binary dropout mask that will be multiplied with the input.
For instance, if your inputs have shape
`(batch_size, timesteps, features)` and
you want the 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 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 = self._validate_noise_shape(noise_shape)
if rate > 0:
self.seed_generator = backend.random.SeedGenerator(seed)
self.supports_masking = True
self._build_at_init()
def _validate_noise_shape(self, noise_shape):
if noise_shape is None:
return None
if isinstance(noise_shape, str):View on GitHub (pinned to 7a34a03db6)
When it happens
Trigger: Thrown at keras/src/layers/regularization/dropout.py:44 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/6d64d04aec450dec.
Report an issue: GitHub.