{"record":{"id":"ef30c8bb2331b043","repo":"keras-team/keras","slug":"invalid-value-received-for-argument-noise-shape","errorCode":null,"errorMessage":"Invalid value received for argument `noise_shape`. Expected a tuple or list of integers. Received: noise_shape={noise_shape}","messagePattern":"Invalid value received for argument `noise_shape`\\. Expected a tuple or list of integers\\. Received: noise_shape=(.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/regularization/dropout.py","lineNumber":63,"sourceCode":"                f\"Invalid value received for argument \"\n                \"`rate`. Expected a float value between 0 and 1. \"\n                f\"Received: rate={rate}\"\n            )\n        self.rate = rate\n        self.seed = seed\n        self.noise_shape = self._validate_noise_shape(noise_shape)\n        if rate > 0:\n            self.seed_generator = backend.random.SeedGenerator(seed)\n        self.supports_masking = True\n\n        self._build_at_init()\n\n    def _validate_noise_shape(self, noise_shape):\n        if noise_shape is None:\n            return None\n\n        if isinstance(noise_shape, str):\n            raise ValueError(\n                f\"Invalid value received for argument `noise_shape`. \"\n                f\"Expected a tuple or list of integers. \"\n                f\"Received: noise_shape={noise_shape}\"\n            )\n\n        if not isinstance(noise_shape, tuple):\n            try:\n                noise_shape = tuple(noise_shape)\n            except TypeError:\n                raise ValueError(\n                    f\"Invalid value received for argument `noise_shape`. \"\n                    f\"Expected an iterable of integers \"\n                    f\"(e.g., a tuple or list). \"\n                    f\"Received: noise_shape={noise_shape}\"\n                )\n\n        for i, dim in enumerate(noise_shape):\n            if dim is not None:","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/regularization/dropout.py#L45-L81","documentation":"Raised by Dropout._validate_noise_shape when `noise_shape` is a Python string. Strings are iterable, so they would otherwise be silently treated as sequences of characters; the validator explicitly rejects them and expects a tuple or list of integers describing the binary dropout mask shape.","triggerScenarios":"Thrown at keras/src/layers/regularization/dropout.py:63 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass `noise_shape` as a tuple/list of ints, e.g. noise_shape=(batch_size, 1, features)","Do not pass a string; if the shape arrives as text, parse it into a tuple of integers first"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}