{"record":{"id":"305f1c9f8e30dd0e","repo":"keras-team/keras","slug":"the-number-of-repeats-in-efficientnet-must-be","errorCode":null,"errorMessage":"The number of repeats in `EfficientNet` must be > 0. Received: repeats={args['repeats']}","messagePattern":"The number of repeats in `EfficientNet` must be > 0\\. Received: repeats=(.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/applications/efficientnet.py","lineNumber":362,"sourceCode":"        round_filters(32),\n        3,\n        strides=2,\n        padding=\"valid\",\n        use_bias=False,\n        kernel_initializer=CONV_KERNEL_INITIALIZER,\n        name=\"stem_conv\",\n    )(x)\n    x = layers.BatchNormalization(axis=bn_axis, name=\"stem_bn\")(x)\n    x = layers.Activation(activation, name=\"stem_activation\")(x)\n\n    # Build blocks\n    blocks_args = copy.deepcopy(blocks_args)\n\n    b = 0\n    blocks = float(sum(round_repeats(args[\"repeats\"]) for args in blocks_args))\n    for i, args in enumerate(blocks_args):\n        if args[\"repeats\"] <= 0:\n            raise ValueError(\n                f\"The number of repeats in `EfficientNet` must be > 0. \"\n                f\"Received: repeats={args['repeats']}\"\n            )\n        # Update block input and output filters based on depth multiplier.\n        args[\"filters_in\"] = round_filters(args[\"filters_in\"])\n        args[\"filters_out\"] = round_filters(args[\"filters_out\"])\n\n        for j in range(round_repeats(args.pop(\"repeats\"))):\n            # The first block needs to take care of stride and filter size\n            # increase.\n            if j > 0:\n                args[\"strides\"] = 1\n                args[\"filters_in\"] = args[\"filters_out\"]\n            x = block(\n                x,\n                activation,\n                drop_connect_rate * b / blocks,\n                name=f\"block{i + 1}{chr(j + 97)}_\",","sourceCodeStart":344,"sourceCodeEnd":380,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/applications/efficientnet.py#L344-L380","documentation":"Cropping output-spec check that bottom_cropping (explicit or inferred as height - target_height - top_cropping) is non-negative; otherwise the vertical crop exceeds the input height.","triggerScenarios":"Negative bottom_cropping argument, or inferred negative when top_cropping + target_height > height.","commonSituations":"Center-crop helpers computing crop = (size - target)/2 with target > size; height/width swaps; wrong data_format axis.","solutions":["Lower target_height or the other cropping so the sum fits within height","Use padding to enlarge","Verify data_format when computing axes"],"exampleFix":"# before\nout = ops.image.crop_images(img, target_height=(100, 100), top_cropping=50)  # height 120\n# after\nout = ops.image.crop_images(img, target_height=(100, 100), top_cropping=20)","handlingStrategy":"validation","validationCode":"top = top_cropping or 0\nassert (bottom_cropping is None or bottom_cropping >= 0) and top + target_height <= height","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate crop amounts against the input height each batch","Watch for height/width swaps in target tuples"],"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"}