{"record":{"id":"46a072969a9e342b","repo":"keras-team/keras","slug":"input-shapes-x1-shape-and-x2-shape-must-match-46a072","errorCode":null,"errorMessage":"Input shapes {x1.shape} and {x2.shape} must match for PSNR calculation. ","messagePattern":"Input shapes (.+?) and (.+?) must match for PSNR calculation\\. ","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/backend/numpy/ops/nn.py","lineNumber":1347,"sourceCode":"        )\n    elif strategy == \"beam_search\":\n        return _ctc_beam_search_decode(\n            inputs,\n            sequence_lengths,\n            beam_width=beam_width,\n            top_paths=top_paths,\n            mask_index=mask_index,\n        )\n    else:\n        raise ValueError(\n            f\"Invalid strategy {strategy}. Supported values are \"\n            \"'greedy' and 'beam_search'.\"\n        )\n\n\ndef psnr(x1, x2, max_val):\n    if x1.shape != x2.shape:\n        raise ValueError(\n            f\"Input shapes {x1.shape} and {x2.shape} must \"\n            \"match for PSNR calculation. \"\n        )\n\n    max_val = convert_to_tensor(max_val, dtype=x2.dtype)\n    mse = np.mean(np.square(x1 - x2))\n    psnr = 20 * np.log10(max_val) - 10 * np.log10(mse)\n    return psnr\n\n\ndef _get_large_negative(dtype):\n    dtype = backend.standardize_dtype(dtype)\n    val = 65500.0 if dtype == \"float16\" else 3.38953e38\n    return np.asarray(val * -0.7, dtype=dtype)\n\n\ndef _apply_masks(logits, mask, is_causal):\n    if mask is None and not is_causal:","sourceCodeStart":1329,"sourceCodeEnd":1365,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/backend/numpy/ops/nn.py#L1329-L1365","documentation":"Error \"Input shapes {x1.shape} and {x2.shape} must match for PSNR calculation. \" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/backend/numpy/ops/nn.py:1347 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}