keras-team/keras · error · ValueError

target_height must be >= 0. Received: target_height={target_

Error message

target_height must be >= 0. Received: target_height={target_height}

What it means

Error "target_height must be >= 0. Received: target_height={target_height}" thrown in keras-team/keras.

Source

Thrown at keras/src/ops/image.py:1688

        if height is not None:
            top_padding = self.top_padding
            bottom_padding = self.bottom_padding
            if top_padding is None:
                top_padding = target_height - height - bottom_padding
            if bottom_padding is None:
                bottom_padding = target_height - height - top_padding
            if top_padding < 0:
                raise ValueError(
                    "top_padding must be >= 0. "
                    f"Received: top_padding={top_padding}"
                )
            if bottom_padding < 0:
                raise ValueError(
                    "bottom_padding must be >= 0. "
                    f"Received: bottom_padding={bottom_padding}"
                )
            if target_height < 0:
                raise ValueError(
                    "target_height must be >= 0. "
                    f"Received: target_height={target_height}"
                )

        if width is not None:
            left_padding = self.left_padding
            right_padding = self.right_padding
            if left_padding is None:
                left_padding = target_width - width - right_padding
            if right_padding is None:
                right_padding = target_width - width - left_padding
            if left_padding < 0:
                raise ValueError(
                    "left_padding must be >= 0. "
                    f"Received: left_padding={left_padding}"
                )
            if right_padding < 0:
                raise ValueError(

View on GitHub (pinned to 7a34a03db6)

When it happens

Trigger: Thrown at keras/src/ops/image.py:1688 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25). Data as JSON: /api/errors/260f48554b7030d7. Report an issue: GitHub.