{"record":{"id":"c92187c43509b900","repo":"keras-team/keras","slug":"the-scale-argument-should-be-a-number-in-the-ran","errorCode":null,"errorMessage":"The `scale` argument should be a number in the range [0,1]. Received: scale={scale}","messagePattern":"The `scale` argument should be a number in the range \\[0,1\\]\\. Received: scale=(.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/preprocessing/image_preprocessing/random_perspective.py","lineNumber":78,"sourceCode":"        factor=1.0,\n        scale=1.0,\n        interpolation=\"bilinear\",\n        fill_value=0.0,\n        seed=None,\n        data_format=None,\n        **kwargs,\n    ):\n        super().__init__(data_format=data_format, **kwargs)\n        self._set_factor(factor)\n        self.scale = scale\n        self.fill_value = fill_value\n        self.interpolation = interpolation\n        self.seed = seed\n        self.generator = SeedGenerator(seed)\n        self.supports_jit = False\n\n        if scale < 0.0 or scale > 1.0:\n            raise ValueError(\n                \"The `scale` argument should be a number \"\n                \"in the range \"\n                f\"[0,1]. \"\n                f\"Received: scale={scale}\"\n            )\n\n        if interpolation not in self._SUPPORTED_INTERPOLATION:\n            raise NotImplementedError(\n                f\"Unknown `interpolation` {interpolation}. Expected of one \"\n                f\"{self._SUPPORTED_INTERPOLATION}.\"\n            )\n\n        if self.data_format == \"channels_first\":\n            self.height_axis = -2\n            self.width_axis = -1\n            self.channel_axis = -3\n        else:\n            self.height_axis = -3","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/preprocessing/image_preprocessing/random_perspective.py#L60-L96","documentation":"RandomPerspective uses `scale` to bound the random displacement of corner points; values must stay within [0, 1] to remain a valid perturbation. This ValueError fires at construction when scale is negative or greater than 1.","triggerScenarios":"Thrown at keras/src/layers/preprocessing/image_preprocessing/random_perspective.py:78 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a scale value in [0, 1]; larger values do not increase distortion beyond the image corners","Pass scale=0.0 for an identity transform or 1.0 for maximum distortion"],"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"}