{"record":{"id":"2a40a22374b99f2e","repo":"keras-team/keras","slug":"received-input-number-input-number-2a40a2","errorCode":null,"errorMessage":"Received: input_number={input_number}","messagePattern":"Received: input_number=(.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/preprocessing/image_preprocessing/solarization.py","lineNumber":121,"sourceCode":"                    self._FACTOR_VALIDATION_ERROR\n                    + f\"Received: {factor_name}={factor}\"\n                )\n            self._check_factor_range(factor[0])\n            self._check_factor_range(factor[1])\n            lower, upper = sorted(factor)\n        elif isinstance(factor, (int, float)):\n            self._check_factor_range(factor)\n            lower, upper = [0, factor]\n        else:\n            raise ValueError(\n                self._FACTOR_VALIDATION_ERROR\n                + f\"Received: {factor_name}={factor}\"\n            )\n        return lower, upper\n\n    def _check_factor_range(self, input_number):\n        if input_number > 1.0 or input_number < 0:\n            raise ValueError(\n                self._FACTOR_VALIDATION_ERROR\n                + f\"Received: input_number={input_number}\"\n            )\n\n    def get_random_transformation(self, data, training=True, seed=None):\n        if not training:\n            return None\n\n        if isinstance(data, dict):\n            images = data[\"images\"]\n        else:\n            images = data\n        images_shape = self.backend.shape(images)\n        if len(images_shape) == 4:\n            factor_shape = (images_shape[0], 1, 1, 1)\n        else:\n            factor_shape = (1, 1, 1)\n","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/preprocessing/image_preprocessing/solarization.py#L103-L139","documentation":"Raised by Solarization's _check_factor_range when a threshold_factor value is greater than 1.0 or less than 0. The threshold is expressed as a fraction of the value range, so it must lie in [0, 1].","triggerScenarios":"Calling Solarization(threshold_factor=1.5) or threshold_factor=(-0.2, 0.8).","commonSituations":"Passing an absolute pixel value (e.g. 128) instead of a fraction (128/255 ≈ 0.5); migrating from TF Addons' Solarize which took 8-bit thresholds.","solutions":["Normalize the threshold to a fraction of the value range, e.g. 128/255 ≈ 0.5 for uint8 data","Keep values within [0, 1]"],"exampleFix":"// before\nlayer = Solarization(value_range=(0, 255), threshold_factor=128)\n// after\nlayer = Solarization(value_range=(0, 255), threshold_factor=128/255)","handlingStrategy":"validation","validationCode":"vals = tf if isinstance(tf, (tuple, list)) else [tf]\nassert all(0.0 <= x <= 1.0 for x in vals), 'threshold_factor must be within [0, 1]'","typeGuard":"def in_unit_range(x):\n    return isinstance(x, (int, float)) and 0.0 <= x <= 1.0","tryCatchPattern":"try:\n    layer = Solarization(value_range=(0, 255), threshold_factor=tf)\nexcept ValueError:\n    tf = max(0.0, min(1.0, tf / value_range[1]))\n    layer = Solarization(value_range=(0, 255), threshold_factor=tf)","preventionTips":["Normalize absolute thresholds by the max of value_range","Remember threshold_factor is a fraction, unlike TF Addons' Solarize 0-255 threshold"],"tags":["keras","preprocessing","range-validation","augmentation"],"backgroundTag":"argument-out-of-range","analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}