keras-team/keras · error · ValueError
Input shapes {x1.shape} and {x2.shape} must match for PSNR c
Error message
Input shapes {x1.shape} and {x2.shape} must match for PSNR calculation. What it means
Error "Input shapes {x1.shape} and {x2.shape} must match for PSNR calculation. " thrown in keras-team/keras.
Source
Thrown at keras/src/backend/numpy/ops/nn.py:1347
)
elif strategy == "beam_search":
return _ctc_beam_search_decode(
inputs,
sequence_lengths,
beam_width=beam_width,
top_paths=top_paths,
mask_index=mask_index,
)
else:
raise ValueError(
f"Invalid strategy {strategy}. Supported values are "
"'greedy' and 'beam_search'."
)
def psnr(x1, x2, max_val):
if x1.shape != x2.shape:
raise ValueError(
f"Input shapes {x1.shape} and {x2.shape} must "
"match for PSNR calculation. "
)
max_val = convert_to_tensor(max_val, dtype=x2.dtype)
mse = np.mean(np.square(x1 - x2))
psnr = 20 * np.log10(max_val) - 10 * np.log10(mse)
return psnr
def _get_large_negative(dtype):
dtype = backend.standardize_dtype(dtype)
val = 65500.0 if dtype == "float16" else 3.38953e38
return np.asarray(val * -0.7, dtype=dtype)
def _apply_masks(logits, mask, is_causal):
if mask is None and not is_causal:View on GitHub (pinned to 7a34a03db6)
When it happens
Trigger: Thrown at keras/src/backend/numpy/ops/nn.py:1347 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/46a072969a9e342b.
Report an issue: GitHub.