{"record":{"id":"a4d224dbc9f5c155","repo":"keras-team/keras","slug":"must-specify-exactly-two-of-top-cropping-bottom-c","errorCode":null,"errorMessage":"Must specify exactly two of top_cropping, bottom_cropping, target_height. Received: top_cropping={top_cropping}, bottom_cropping={bottom_cropping}, target_height={target_height}","messagePattern":"Must specify exactly two of top_cropping, bottom_cropping, target_height\\. Received: top_cropping=(.+?), bottom_cropping=(.+?), target_height=(.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/ops/image.py","lineNumber":1581,"sourceCode":"\n    _validate_non_negative(top_padding, \"top_padding\")\n    _validate_non_negative(bottom_padding, \"bottom_padding\")\n    _validate_non_negative(target_height, \"target_height\")\n    _validate_non_negative(left_padding, \"left_padding\")\n    _validate_non_negative(right_padding, \"right_padding\")\n    _validate_non_negative(target_width, \"target_width\")\n\n\ndef _validate_crop_images_args(\n    top_cropping,\n    left_cropping,\n    bottom_cropping,\n    right_cropping,\n    target_height,\n    target_width,\n):\n    if [top_cropping, bottom_cropping, target_height].count(None) != 1:\n        raise ValueError(\n            \"Must specify exactly two of \"\n            \"top_cropping, bottom_cropping, target_height. \"\n            f\"Received: top_cropping={top_cropping}, \"\n            f\"bottom_cropping={bottom_cropping}, \"\n            f\"target_height={target_height}\"\n        )\n    if [left_cropping, right_cropping, target_width].count(None) != 1:\n        raise ValueError(\n            \"Must specify exactly two of \"\n            \"left_cropping, right_cropping, target_width. \"\n            f\"Received: left_cropping={left_cropping}, \"\n            f\"right_cropping={right_cropping}, \"\n            f\"target_width={target_width}\"\n        )\n\n    _validate_non_negative(top_cropping, \"top_cropping\")\n    _validate_non_negative(bottom_cropping, \"bottom_cropping\")\n    _validate_non_negative(target_height, \"target_height\")","sourceCodeStart":1563,"sourceCodeEnd":1599,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/ops/image.py#L1563-L1599","documentation":"crop_images (and its layer) requires exactly two of top_cropping, bottom_cropping, target_height; the third is derived. Zero, one, or three specified values make the vertical crop ambiguous and the validator raises.","triggerScenarios":"keras.ops.image.crop_images(images) with all cropping args None, a single value, or all three given.","commonSituations":"Default-constructing the op expecting a no-op; mixing pad-style kwargs (padding) into crop; config templates where one bound is always set plus target, accidentally also setting the third.","solutions":["Specify exactly two, e.g. crop_images(img, target_height=224, top_cropping=0)","Center-crop style: top_cropping=(H-target)//2 style values on both sides","Remove the redundant third argument"],"exampleFix":"# before\nout = crop_images(img, target_height=224)\n\n# after\nout = crop_images(img, target_height=224, top_cropping=0)","handlingStrategy":"validation","validationCode":"assert [top_cropping, bottom_cropping, target_height].count(None) == 1","typeGuard":"def crop_height_triple_ok(t, b, th) -> bool:\n    return [t, b, th].count(None) == 1","tryCatchPattern":null,"preventionTips":["Mirror the pad_images calling convention","Reject configs with 0 or 3 values at load time"],"tags":["keras","image","cropping","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"}