affine_transform does not validate that the last dimension of transform shape is 8
Author: NoxtimoCreated Sep 25, 2026Updated Sep 28, 2026
Labelstype:Bug
Summary
keras.ops.image.affine_transform and keras.ops.image.AffineTransform validate that transform has rank 1 or rank 2, but do not validate that its last dimension equals 8 when statically known.
Current Behavior
Passing a transform where the last dimension is not 8 (such as shape (6,) or (None, 6)) causes inconsistent behavior across backends:
- In symbolic mode (
KerasTensor), invalid shapes pass without error. - On OpenVINO, an invalid shape such as
(6,)produces an output without raising an error. - On other backends, errors vary from
TypeError(JAX),IndexError/ValueError(NumPy),RuntimeError(Torch), toInvalidArgumentError(TensorFlow).
Expected Behavior
Both eager and symbolic execution should validate that when transform.shape[-1] is statically known, it must equal 8, raising a consistent ValueError:
ValueError: Invalid transform shape: expected the last dimension to be 8. Received: transform.shape=...I have a fix with tests ready for this. Could you please assign this issue to me?
Source: keras-team/keras