keras-team/keras · error · ValueError
`cropping` should be either an int, a tuple of 2 ints (symme
Error message
`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)). Received: cropping={cropping}. What it means
Error "`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)). Received: cropping={cropping}." thrown in keras-team/keras.
Source
Thrown at keras/src/layers/reshaping/cropping2d.py:80
"`cropping` cannot be negative. "
f"Received: cropping={cropping}."
)
self.cropping = ((cropping, cropping), (cropping, cropping))
elif hasattr(cropping, "__len__"):
if len(cropping) != 2:
raise ValueError(
"`cropping` should have two elements. "
f"Received: cropping={cropping}."
)
height_cropping = argument_validation.standardize_tuple(
cropping[0], 2, "1st entry of cropping", allow_zero=True
)
width_cropping = argument_validation.standardize_tuple(
cropping[1], 2, "2nd entry of cropping", allow_zero=True
)
self.cropping = (height_cropping, width_cropping)
else:
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(View on GitHub (pinned to 7a34a03db6)
When it happens
Trigger: Thrown at keras/src/layers/reshaping/cropping2d.py:80 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/b5e6b84f298ed8a9.
Report an issue: GitHub.