keras-team/keras · error · ValueError
Values in `cropping` argument should be smaller than the cor
Error message
Values in `cropping` argument should be smaller than the corresponding spatial dimension of the input. Received: input_shape={input_shape}, cropping={self.cropping} What it means
Error "Values in `cropping` argument should be smaller than the corresponding spatial dimension of the input. Received: input_shape={input_shape}, cropping={self.cropping}" thrown in keras-team/keras.
Source
Thrown at keras/src/layers/reshaping/cropping2d.py:98
raise ValueError(
"`cropping` should be either an int, a tuple of 2 ints "
"(symmetric_height_crop, symmetric_width_crop), "
"or a tuple of 2 tuples of 2 ints "
"((top_crop, bottom_crop), (left_crop, right_crop)). "
f"Received: cropping={cropping}."
)
self.input_spec = InputSpec(ndim=4)
def compute_output_shape(self, input_shape):
if self.data_format == "channels_first":
if (
input_shape[2] is not None
and sum(self.cropping[0]) >= input_shape[2]
) or (
input_shape[3] is not None
and sum(self.cropping[1]) >= input_shape[3]
):
raise ValueError(
"Values in `cropping` argument should be smaller than the "
"corresponding spatial dimension of the input. Received: "
f"input_shape={input_shape}, cropping={self.cropping}"
)
return (
input_shape[0],
input_shape[1],
(
input_shape[2] - self.cropping[0][0] - self.cropping[0][1]
if input_shape[2] is not None
else None
),
(
input_shape[3] - self.cropping[1][0] - self.cropping[1][1]
if input_shape[3] is not None
else None
),
)View on GitHub (pinned to 7a34a03db6)
When it happens
Trigger: Thrown at keras/src/layers/reshaping/cropping2d.py:98 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/24f11c4d5dea2ac2.
Report an issue: GitHub.