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
Raised by RandomTranslation's constructor when `interpolation` is not one of "nearest" or "bilinear". Only these two resampling methods are implemented for translating images.
Source
Thrown at keras/src/layers/preprocessing/image_preprocessing/random_translation.py:134
**kwargs,
):
super().__init__(data_format=data_format, **kwargs)
self.height_factor = height_factor
self.height_lower, self.height_upper = self._set_factor(
height_factor, "height_factor"
)
self.width_factor = width_factor
self.width_lower, self.width_upper = self._set_factor(
width_factor, "width_factor"
)
if fill_mode not in self._SUPPORTED_FILL_MODE:
raise NotImplementedError(
f"Unknown `fill_mode` {fill_mode}. Expected of one "
f"{self._SUPPORTED_FILL_MODE}."
)
if interpolation not in self._SUPPORTED_INTERPOLATION:
raise NotImplementedError(
f"Unknown `interpolation` {interpolation}. Expected of one "
f"{self._SUPPORTED_INTERPOLATION}."
)
self.fill_mode = fill_mode
self.fill_value = fill_value
self.interpolation = interpolation
self.seed = seed
self.generator = SeedGenerator(seed)
self.supports_jit = False
def _set_factor(self, factor, factor_name):
if isinstance(factor, (tuple, list)):
if len(factor) != 2:
raise ValueError(
self._FACTOR_VALIDATION_ERROR
+ f"Received: {factor_name}={factor}"
)View on GitHub (pinned to 7a34a03db6)
Solutions
- Use "bilinear" for smooth results or "nearest" for speed
- If you need bicubic-quality augmentation, resize before/after the layer or use RandomRotation/RandomZoom if they support it in your Keras version
Example fix
// before layer = RandomTranslation(0.1, 0.1, interpolation="bicubic") // after layer = RandomTranslation(0.1, 0.1, interpolation="bilinear")
Defensive patterns
Strategy: validation
Validate before calling
assert interpolation in {"nearest", "bilinear"}, 'RandomTranslation supports only nearest/bilinear' Type guard
def is_valid_interp(v):
return v in {"nearest", "bilinear"} Try / catch
try:
layer = RandomTranslation(0.1, 0.1, interpolation=interp)
except NotImplementedError:
interp = "bilinear"
layer = RandomTranslation(0.1, 0.1, interpolation=interp) Prevention
- Don't assume tf.image.resize interpolation names transfer to preprocessing layers
- Default to "bilinear" unless speed requires "nearest"
When it happens
Trigger: Calling RandomTranslation(..., interpolation="bicubic") or interpolation="lanczos".
Common situations: Reusing interpolation strings from tf.image.resize (which supports 'bicubic', 'lanczos3', etc.) or from other Keras preprocessing layers like RandomRotation which accept "bicubic" in newer versions.
Related errors
- Unknown `interpolation` {interpolation}. Expected of one {se
- The `factor` argument should be a number (or a list of two n
- The `factor` argument should be a number (or a list of two n
- Unknown `fill_mode` {fill_mode}. Expected of one {self._SUPP
- Received: {factor_name}={factor}
AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25).
Data as JSON: /api/errors/a933a60fd0b86f0f.
Report an issue: GitHub.