{"record":{"id":"2a2a4e0f141152f2","repo":"keras-team/keras","slug":"must-specify-exactly-two-of-top-padding-bottom-pa","errorCode":null,"errorMessage":"Must specify exactly two of top_padding, bottom_padding, target_height. Received: top_padding={top_padding}, bottom_padding={bottom_padding}, target_height={target_height}","messagePattern":"Must specify exactly two of top_padding, bottom_padding, target_height\\. Received: top_padding=(.+?), bottom_padding=(.+?), target_height=(.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/ops/image.py","lineNumber":1548,"sourceCode":"        fill_value,\n    )\n\n\ndef _validate_non_negative(value, name):\n    if value is not None and value < 0:\n        raise ValueError(f\"{name} must be >= 0. Received: {name}={value}\")\n\n\ndef _validate_pad_images_args(\n    top_padding,\n    left_padding,\n    bottom_padding,\n    right_padding,\n    target_height,\n    target_width,\n):\n    if [top_padding, bottom_padding, target_height].count(None) != 1:\n        raise ValueError(\n            \"Must specify exactly two of \"\n            \"top_padding, bottom_padding, target_height. \"\n            f\"Received: top_padding={top_padding}, \"\n            f\"bottom_padding={bottom_padding}, \"\n            f\"target_height={target_height}\"\n        )\n    if [left_padding, right_padding, target_width].count(None) != 1:\n        raise ValueError(\n            \"Must specify exactly two of \"\n            \"left_padding, right_padding, target_width. \"\n            f\"Received: left_padding={left_padding}, \"\n            f\"right_padding={right_padding}, \"\n            f\"target_width={target_width}\"\n        )\n\n    _validate_non_negative(top_padding, \"top_padding\")\n    _validate_non_negative(bottom_padding, \"bottom_padding\")\n    _validate_non_negative(target_height, \"target_height\")","sourceCodeStart":1530,"sourceCodeEnd":1566,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/ops/image.py#L1530-L1566","documentation":"pad_images (and its layer) requires exactly two of top_padding, bottom_padding, target_height to be given (the third is derived). This validator raises when zero, one, or all three are None — the vertical output size is then over- or under-determined.","triggerScenarios":"keras.ops.image.pad_images(images) with none of the three set (all None defaults), or with all three set, or only one set.","commonSituations":"Calling pad_images with no arguments expecting a no-op; copying a partial config where one of the three keys is missing or extra; version migration where target_height was previously optional.","solutions":["Specify exactly two, e.g. pad_images(img, target_height=256, bottom_padding=8)","For symmetric pad of known amount: top_padding=b, bottom_padding=b and leave target None","For pad-to-size: target_height plus one side"],"exampleFix":"# before\nout = pad_images(img)\n\n# after\nout = pad_images(img, top_padding=8, bottom_padding=8)","handlingStrategy":"validation","validationCode":"assert [top_padding, bottom_padding, target_height].count(None) == 1","typeGuard":"def height_triple_ok(t, b, th) -> bool:\n    return [t, b, th].count(None) == 1","tryCatchPattern":null,"preventionTips":["Decide pad-to-size vs pad-by-amount up front","Test both axes' triples in unit tests of the config"],"tags":["keras","image","padding","argument-validation"],"backgroundTag":"missing-or-conflicting-arguments","analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}