{"record":{"id":"0be04593694ebadd","repo":"keras-team/keras","slug":"for-padding-same-output-size-height-h-m","errorCode":null,"errorMessage":"For `padding='same'`, `output_size` height ({H}) must be in the range ((gH-1)*pH, gH*pH], i.e. ({static_gH * pH - pH}, {static_gH * pH}]. Got: gH={static_gH}, pH={pH}.","messagePattern":"For `padding='same'`, `output_size` height \\((.+?)\\) must be in the range \\(\\(gH-1\\)\\*pH, gH\\*pH\\], i\\.e\\. \\((.+?), (.+?)\\]\\. Got: gH=(.+?), pH=(.+?)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/ops/image.py","lineNumber":1286,"sourceCode":"    else:\n        if static_flat % (pH * pW) != 0:\n            raise ValueError(\n                f\"`patches` last dim ({static_flat}) is not divisible by \"\n                f\"prod(size) ({pH * pW}).\"\n            )\n        C = static_flat // (pH * pW)\n\n    x = backend.numpy.reshape(patches, (B, gH, gW, pH, pW, C))\n    x = backend.numpy.transpose(x, axes=(0, 1, 3, 2, 4, 5))\n    x = backend.numpy.reshape(x, (B, gH * pH, gW * pW, C))\n\n    if padding == \"same\":\n        static_gH = patches.shape[1]\n        static_gW = patches.shape[2]\n        if isinstance(static_gH, int) and not (\n            static_gH * pH - pH < H <= static_gH * pH\n        ):\n            raise ValueError(\n                f\"For `padding='same'`, `output_size` height ({H}) must \"\n                f\"be in the range ((gH-1)*pH, gH*pH], i.e. \"\n                f\"({static_gH * pH - pH}, {static_gH * pH}]. \"\n                f\"Got: gH={static_gH}, pH={pH}.\"\n            )\n        if isinstance(static_gW, int) and not (\n            static_gW * pW - pW < W <= static_gW * pW\n        ):\n            raise ValueError(\n                f\"For `padding='same'`, `output_size` width ({W}) must \"\n                f\"be in the range ((gW-1)*pW, gW*pW], i.e. \"\n                f\"({static_gW * pW - pW}, {static_gW * pW}]. \"\n                f\"Got: gW={static_gW}, pW={pW}.\"\n            )\n        pad_total_h = gH * pH - H\n        pad_total_w = gW * pW - W\n        begin = [0, pad_total_h // 2, pad_total_w // 2, 0]\n        out_shape = [B, H, W, C]","sourceCodeStart":1268,"sourceCodeEnd":1304,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/ops/image.py#L1268-L1304","documentation":"Error \"For `padding='same'`, `output_size` height ({H}) must be in the range ((gH-1)*pH, gH*pH], i.e. ({static_gH * pH - pH}, {static_gH * pH}]. Got: gH={static_gH}, pH={pH}.\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/ops/image.py:1286 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"}