keras-team/keras · error · ValueError
Invalid value for argument `interpolation`. Expected of one
Error message
Invalid value for argument `interpolation`. Expected of one {AFFINE_TRANSFORM_INTERPOLATIONS}. Received: interpolation={interpolation} What it means
Raised by the input-validation guard at the top of keras/src/backend/tensorflow/image.py affine_transform when the interpolation string is not one of the module-level AFFINE_TRANSFORM_INTERPOLATIONS constants. The interpolation argument controls the resampling kernel used by the affine warp; an unrecognized string means the caller passed a method name that this TensorFlow backend implementation does not support (e.g. a JAX-only name or a typo like 'bilineer').
Solutions
- Pass one of the supported interpolation names, e.g. interpolation="bilinear"
- Check AFFINE_TRANSFORM_INTERPOLATIONS in keras.src.backend.tensorflow.image for the exact accepted set
- Fix typos or backend-specific interpolation names in the calling code
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at keras/src/backend/tensorflow/image.py:352 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25).
Data as JSON: /api/errors/57b4385e69e9c79d.
Report an issue: GitHub.
Appendix: source
Thrown at keras/src/backend/tensorflow/image.py:352
if data_format == "channels_first":
if len(images.shape) == 4:
resized = tf.transpose(resized, (0, 3, 1, 2))
elif len(images.shape) == 3:
resized = tf.transpose(resized, (2, 0, 1))
return resized
def affine_transform(
images,
transform,
interpolation="bilinear",
fill_mode="constant",
fill_value=0,
data_format=None,
):
data_format = backend.standardize_data_format(data_format)
if interpolation not in AFFINE_TRANSFORM_INTERPOLATIONS:
raise ValueError(
"Invalid value for argument `interpolation`. Expected of one "
f"{AFFINE_TRANSFORM_INTERPOLATIONS}. Received: "
f"interpolation={interpolation}"
)
if fill_mode not in AFFINE_TRANSFORM_FILL_MODES:
raise ValueError(
"Invalid value for argument `fill_mode`. Expected of one "
f"{AFFINE_TRANSFORM_FILL_MODES}. Received: fill_mode={fill_mode}"
)
if len(images.shape) not in (3, 4):
raise ValueError(
"Invalid images rank: expected rank 3 (single image) "
"or rank 4 (batch of images). Received input with shape: "
f"images.shape={images.shape}"
)
if len(transform.shape) not in (1, 2):
raise ValueError(
"Invalid transform rank: expected rank 1 (single transform) "View on GitHub (pinned to 7a34a03db6)