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 RandomZoom's constructor when `interpolation` is not "nearest" or "bilinear". These are the only resampling methods implemented for the zoom transform.
Source
Thrown at keras/src/layers/preprocessing/image_preprocessing/random_zoom.py:135
**kwargs,
):
super().__init__(**kwargs)
self.height_factor = height_factor
self.height_lower, self.height_upper = self._set_factor(
height_factor, "height_factor"
)
self.width_factor = width_factor
if width_factor is not None:
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.data_format = backend.standardize_data_format(data_format)
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" (default, smooth) or "nearest" (fast)
- Pre/post-resize with tf.image.resize if you need higher-order interpolation
Example fix
// before layer = RandomZoom(0.2, interpolation="area") // after layer = RandomZoom(0.2, interpolation="bilinear")
Defensive patterns
Strategy: validation
Validate before calling
assert interpolation in {"nearest", "bilinear"}, 'RandomZoom supports only nearest/bilinear' Type guard
def is_valid_interp(v):
return v in {"nearest", "bilinear"} Try / catch
try:
layer = RandomZoom(0.2, interpolation=interp)
except NotImplementedError:
layer = RandomZoom(0.2, interpolation="bilinear") Prevention
- Restrict config schemas to the two supported values
- Do extra resampling outside the layer if higher-order interpolation is needed
When it happens
Trigger: Calling RandomZoom(0.2, interpolation="bicubic") or "area".
Common situations: Copying interpolation settings from tf.image.resize or another layer/version that supports more methods; assuming OpenCV-style flags work.
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/b51d99e155937e8f.
Report an issue: GitHub.