{"record":{"id":"22e03610cf363b87","repo":"keras-team/keras","slug":"unknown-fill-mode-fill-mode-expected-of-one","errorCode":null,"errorMessage":"Unknown `fill_mode` {fill_mode}. Expected of one {self._SUPPORTED_FILL_MODES}.","messagePattern":"Unknown `fill_mode` (.+?)\\. Expected of one (.+?)\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/preprocessing/image_preprocessing/random_elastic_transform.py","lineNumber":113,"sourceCode":"    ):\n        super().__init__(data_format=data_format, **kwargs)\n        self._set_factor(factor)\n        self.scale = self._set_factor_by_name(scale, \"scale\")\n        self.interpolation = interpolation\n        self.fill_mode = fill_mode\n        self.fill_value = fill_value\n        self.value_range = value_range\n        self.seed = seed\n        self.generator = SeedGenerator(seed)\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 fill_mode not in self._SUPPORTED_FILL_MODES:\n            raise NotImplementedError(\n                f\"Unknown `fill_mode` {fill_mode}. Expected of one \"\n                f\"{self._SUPPORTED_FILL_MODES}.\"\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\n            self.width_axis = -2\n            self.channel_axis = -1\n\n    def _set_factor_by_name(self, factor, name):\n        error_msg = (\n            f\"The `{name}` argument should be a number \"\n            \"(or a list of two numbers) \"\n            \"in the range \"","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/preprocessing/image_preprocessing/random_elastic_transform.py#L95-L131","documentation":"RandomElasticTransform validates fill_mode in __init__ against _SUPPORTED_FILL_MODES. Fill mode controls how pixels mapped outside the input boundary are filled after the elastic warp; only the enumerated modes (e.g. 'reflect', 'wrap', 'constant', 'nearest') are implemented. Any other string raises NotImplementedError at construction.","triggerScenarios":"layers.RandomElasticTransform(fill_mode='replicate') or fill_mode='edge' (Pillow/OpenCV vocabulary), fill_mode='black', or a typo like 'constnat'.","commonSituations":"Porting augmentation configs from albumentations, torchvision, or OpenCV, whose fill-mode names ('replicate', 'edge') differ from Keras's; assuming OpenCV's cv2.BORDER_* constants work unchanged.","solutions":["Use an exact string from RandomElasticTransform._SUPPORTED_FILL_MODES, e.g. 'constant' when pairing it with fill_value","Check the accepted set: print(layers.RandomElasticTransform._SUPPORTED_FILL_MODES)","Map your existing config vocabulary: OpenCV 'replicate' -> 'nearest', 'edge' -> 'nearest'"],"exampleFix":"# before\nlayers.RandomElasticTransform(fill_mode=\"replicate\")\n# after\nlayers.RandomElasticTransform(fill_mode=\"nearest\")","handlingStrategy":"validation","validationCode":"from keras.src.layers.preprocessing.image_preprocessing.random_elastic_transform import RandomElasticTransform\nassert fill_mode in RandomElasticTransform._SUPPORTED_FILL_MODES","typeGuard":"def is_valid_fill_mode(v: str) -> bool:\n    return v in {\"reflect\", \"wrap\", \"constant\", \"nearest\"}","tryCatchPattern":"try:\n    layer = RandomElasticTransform(fill_mode=mode)\nexcept NotImplementedError as e:\n    raise ValueError(f\"bad fill_mode {mode!r}: {e}\") from e","preventionTips":["Translate fill-mode names when porting from OpenCV/Pillow vocabulary","Validate strings against the class constant before constructing"],"tags":["keras","preprocessing","argument-validation","enum"],"backgroundTag":"invalid-enum-argument","analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}