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/jax/ops/nn.py:1447
)
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 = jnp.mean(jnp.square(x1 - x2))
psnr = 20 * jnp.log10(max_val) - 10 * jnp.log10(mse)
return psnr
def _can_use_flash_attention(query, key, value, bias, raise_error=False):
"""Verify the availability of flash attention."""
try:
from jax._src.cudnn.fused_attention_stablehlo import _normalize_layout
from jax._src.cudnn.fused_attention_stablehlo import (
check_compute_capability,
)
from jax._src.cudnn.fused_attention_stablehlo import check_cudnn_versionView on GitHub (pinned to 7a34a03db6)
When it happens
Trigger: Thrown at keras/src/backend/jax/ops/nn.py:1447 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/2527f59a5c086b35.
Report an issue: GitHub.