{"record":{"id":"b47ba1142de55fed","repo":"keras-team/keras","slug":"the-number-of-repeats-in-efficientnetv2-must-be","errorCode":null,"errorMessage":"The number of repeats in `EfficientNetV2` must be > 0. Received: num_repeat={args['num_repeat']}","messagePattern":"The number of repeats in `EfficientNetV2` must be > 0\\. Received: num_repeat=(.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/applications/efficientnet_v2.py","lineNumber":978,"sourceCode":"        padding=\"same\",\n        use_bias=False,\n        name=\"stem_conv\",\n    )(x)\n    x = layers.BatchNormalization(\n        axis=bn_axis,\n        momentum=bn_momentum,\n        name=\"stem_bn\",\n    )(x)\n    x = layers.Activation(activation, name=\"stem_activation\")(x)\n\n    # Build blocks\n    blocks_args = copy.deepcopy(blocks_args)\n    b = 0\n    blocks = float(sum(args[\"num_repeat\"] for args in blocks_args))\n\n    for i, args in enumerate(blocks_args):\n        if args[\"num_repeat\"] <= 0:\n            raise ValueError(\n                f\"The number of repeats in `EfficientNetV2` must be > 0. \"\n                f\"Received: num_repeat={args['num_repeat']}\"\n            )\n\n        # Update block input and output filters based on depth multiplier.\n        args[\"input_filters\"] = round_filters(\n            filters=args[\"input_filters\"],\n            width_coefficient=width_coefficient,\n            min_depth=min_depth,\n            depth_divisor=depth_divisor,\n        )\n        args[\"output_filters\"] = round_filters(\n            filters=args[\"output_filters\"],\n            width_coefficient=width_coefficient,\n            min_depth=min_depth,\n            depth_divisor=depth_divisor,\n        )\n","sourceCodeStart":960,"sourceCodeEnd":996,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/applications/efficientnet_v2.py#L960-L996","documentation":"Cropping output-spec check that right_cropping (explicit or inferred as width - target_width - left_cropping) is non-negative; a negative value means the requested horizontal crop exceeds the image width.","triggerScenarios":"Explicit negative right_cropping, or inferred negative when left_cropping + target_width > width.","commonSituations":"Oversized crop windows from config; random-crop augmentation sampling crops larger than small inputs; pixel-vs-fraction unit confusion.","solutions":["Reduce crop amounts or target_width to fit within width","Use padding first when inputs are smaller than the crop window","Sanitize augmentation parameters against the actual input size"],"exampleFix":"# before\nout = ops.image.crop_images(img, target_width=(48, 48), left_cropping=30)  # width 64\n# after\nout = ops.image.crop_images(img, target_width=(48, 48), left_cropping=16)","handlingStrategy":"validation","validationCode":"if right_cropping is not None:\n    assert right_cropping >= 0 and (left_cropping or 0) + target_width + right_cropping <= width","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate augmentation crop params against real input sizes","Distinguish pixel vs fractional crop units"],"tags":["keras","cropping","validation"],"backgroundTag":"invalid-argument-validation","analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}