keras-team/keras · error · ValueError

Invalid value received for argument `noise_shape`. Expected

Error message

Invalid value received for argument `noise_shape`. Expected all dimensions to be positive integers or None. Received negative or zero value at index {i}: {dim}

What it means

Error "Invalid value received for argument `noise_shape`. Expected all dimensions to be positive integers or None. Received negative or zero value at index {i}: {dim}" thrown in keras-team/keras.

Source

Thrown at keras/src/layers/regularization/dropout.py:91

                raise ValueError(
                    f"Invalid value received for argument `noise_shape`. "
                    f"Expected an iterable of integers "
                    f"(e.g., a tuple or list). "
                    f"Received: noise_shape={noise_shape}"
                )

        for i, dim in enumerate(noise_shape):
            if dim is not None:
                if not isinstance(dim, int):
                    raise ValueError(
                        f"Invalid value received for argument `noise_shape`. "
                        f"Expected all elements to be integers or None. "
                        f"Received element at index {i}: {dim} "
                        f"(type: {type(dim).__name__})"
                    )

                if dim <= 0:
                    raise ValueError(
                        f"Invalid value received for argument `noise_shape`. "
                        f"Expected all dimensions to be positive integers "
                        f"or None. "
                        f"Received negative or zero value at index {i}: {dim}"
                    )

        return noise_shape

    def call(self, inputs, training=False):
        if training and self.rate > 0:
            return backend.random.dropout(
                inputs,
                self.rate,
                noise_shape=self.noise_shape,
                seed=self.seed_generator,
            )
        return inputs

View on GitHub (pinned to 7a34a03db6)

When it happens

Trigger: Thrown at keras/src/layers/regularization/dropout.py:91 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/7faf6f8b1f264408. Report an issue: GitHub.