keras-team/keras · error · NotImplementedError
Unknown `interpolation` {interpolation}. Expected of one {se
Error message
Unknown `interpolation` {interpolation}. Expected of one {self._SUPPORTED_INTERPOLATION}. What it means
RandomElasticTransform validates its interpolation argument in __init__ against the fixed set stored in _SUPPORTED_INTERPOLATION. An unsupported string raises NotImplementedError immediately at construction, so an augmentation that cannot be realized never reaches training. The supported values are those enumerated by the layer (e.g. 'nearest' and 'bilinear').
Source
Thrown at keras/src/layers/preprocessing/image_preprocessing/random_elastic_transform.py:107
fill_mode="reflect",
fill_value=0.0,
value_range=(0, 255),
seed=None,
data_format=None,
**kwargs,
):
super().__init__(data_format=data_format, **kwargs)
self._set_factor(factor)
self.scale = self._set_factor_by_name(scale, "scale")
self.interpolation = interpolation
self.fill_mode = fill_mode
self.fill_value = fill_value
self.value_range = value_range
self.seed = seed
self.generator = SeedGenerator(seed)
if interpolation not in self._SUPPORTED_INTERPOLATION:
raise NotImplementedError(
f"Unknown `interpolation` {interpolation}. Expected of one "
f"{self._SUPPORTED_INTERPOLATION}."
)
if fill_mode not in self._SUPPORTED_FILL_MODES:
raise NotImplementedError(
f"Unknown `fill_mode` {fill_mode}. Expected of one "
f"{self._SUPPORTED_FILL_MODES}."
)
if self.data_format == "channels_first":
self.height_axis = -2
self.width_axis = -1
self.channel_axis = -3
else:
self.height_axis = -3
self.width_axis = -2
self.channel_axis = -1View on GitHub (pinned to 7a34a03db6)
Solutions
- Use one of the exact strings in RandomElasticTransform._SUPPORTED_INTERPOLATION, typically 'nearest' or 'bilinear'
- Print the supported set first: print(layers.RandomElasticTransform._SUPPORTED_INTERPOLATION)
- If you need 'bicubic', pick a layer that supports it or implement a custom transform outside this layer
Example fix
# before layers.RandomElasticTransform(interpolation="bicubic") # after layers.RandomElasticTransform(interpolation="bilinear")
Defensive patterns
Strategy: validation
Validate before calling
from keras.src.layers.preprocessing.image_preprocessing.random_elastic_transform import RandomElasticTransform
interp = "bilinear"
assert interp in RandomElasticTransform._SUPPORTED_INTERPOLATION, f"use one of {RandomElasticTransform._SUPPORTED_INTERPOLATION}" Type guard
def is_valid_interpolation(v: str) -> bool:
return v in {"nearest", "bilinear"} Try / catch
try:
layer = RandomElasticTransform(interpolation=interp)
except NotImplementedError as e:
raise ValueError(f"bad interpolation {interp!r}: {e}") from e Prevention
- Pin interpolation vocabulary to the layer's _SUPPORTED_INTERPOLATION constant
- Add config schema validation when values come from YAML/JSON
When it happens
Trigger: Constructing layers.RandomElasticTransform(interpolation=...) with a misspelled or unsupported string, e.g. interpolation='bicubic', interpolation='Bilinear' (case matters), or interpolation='linear'.
Common situations: Copying interpolation names from other frameworks (PyTorch/torchvision or tf.image use different vocabularies such as 'bicubic'); upgrading Keras versions where the accepted set changed; assuming case-insensitive matching.
Related errors
- Unknown `fill_mode` {fill_mode}. Expected of one {self._SUPP
- The `{name}` argument should be a number (or a list of two n
- The `{name}` argument should be a number (or a list of two n
- The `fill_value` argument should be a number (or a list of t
- The `{name}` argument should be a number (or a list of two n
AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25).
Data as JSON: /api/errors/b48a2e3849314109.
Report an issue: GitHub.