keras-team/keras · error · ValueError
Input should have its {axes} axes fully-defined. Received: i
Error message
Input should have its {axes} axes fully-defined. Received: input.shape = {real.shape} What it means
fft2 needs both FFT axes (-2 and -1) fully defined at symbolic time; if either of the last two dimensions is None, the output shape cannot be computed and Keras raises. The message interpolates the axes tuple, e.g. 'Input should have its (-2, -1) axes fully-defined'.
Source
Thrown at keras/src/ops/math.py:595
if real.shape != imag.shape:
raise ValueError(
"Input `x` should be a tuple of two tensors - real and "
"imaginary. Both the real and imaginary parts should have the "
f"same shape. Received: x[0].shape = {real.shape}, "
f"x[1].shape = {imag.shape}"
)
# We are calculating 2D FFT. Hence, rank >= 2.
if len(real.shape) < 2:
raise ValueError(
f"Input should have rank >= 2. "
f"Received: input.shape = {real.shape}"
)
# The axes along which we are calculating FFT should be fully-defined.
m = real.shape[axes[0]]
n = real.shape[axes[1]]
if m is None or n is None:
raise ValueError(
f"Input should have its {axes} axes fully-defined. "
f"Received: input.shape = {real.shape}"
)
return (
KerasTensor(shape=real.shape, dtype=real.dtype),
KerasTensor(shape=imag.shape, dtype=imag.dtype),
)
def call(self, x):
return backend.math.fft2(x)
@keras_export("keras.ops.fft2")
def fft2(x):
"""Computes the 2D Fast Fourier Transform along the last two axes of input.
Args:View on GitHub (pinned to 7a34a03db6)
Solutions
- Fix both spatial dims: keras.Input(shape=(256, 256))
- Resize all images to a fixed resolution before the FFT (resizing layer or preprocessing)
- Bucket variable-size inputs to fixed sizes
Example fix
# before inputs = keras.Input(shape=(None, None, 1)) out = keras.ops.fft2((inputs[..., 0], inputs[..., 0])) # after inputs = keras.Input(shape=(256, 256, 1)) out = keras.ops.fft2((inputs[..., 0], inputs[..., 0]))
Defensive patterns
Strategy: validation
Validate before calling
assert real.shape[-1] is not None and real.shape[-2] is not None
Prevention
- Fix spatial dims in keras.Input for fft2 models
- Resize inputs to constant resolution
When it happens
Trigger: keras.Input(shape=(None, None)) feeding fft2 in a functional model; variable-height image inputs (dynamic H and W).
Common situations: Variable-resolution image models; eager code moved into a functional graph where dims become None.
Related errors
- Input should have its last dimension fully-defined. Received
- The `weights` argument should be either `None` (random initi
- RandomCrop requires the input to have a fully defined height
- All `axis` values to be kept must have a known shape. Receiv
- R2Score expects 2D inputs with shape (batch_size, output_dim
AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25).
Data as JSON: /api/errors/6a1555651df7458f.
Report an issue: GitHub.