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: inputs.shape={inputs.shape}, cropping={self.cropping} What it means
Error "Values in `cropping` argument should be smaller than the corresponding spatial dimension of the input. Received: inputs.shape={inputs.shape}, cropping={self.cropping}" thrown in keras-team/keras.
Source
Thrown at keras/src/layers/reshaping/cropping2d.py:154
),
(
input_shape[2] - self.cropping[1][0] - self.cropping[1][1]
if input_shape[2] is not None
else None
),
input_shape[3],
)
def call(self, inputs):
if self.data_format == "channels_first":
if (
inputs.shape[2] is not None
and sum(self.cropping[0]) >= inputs.shape[2]
) or (
inputs.shape[3] is not None
and sum(self.cropping[1]) >= inputs.shape[3]
):
raise ValueError(
"Values in `cropping` argument should be smaller than the "
"corresponding spatial dimension of the input. Received: "
f"inputs.shape={inputs.shape}, cropping={self.cropping}"
)
if self.cropping[0][1] == self.cropping[1][1] == 0:
return inputs[
:, :, self.cropping[0][0] :, self.cropping[1][0] :
]
elif self.cropping[0][1] == 0:
return inputs[
:,
:,
self.cropping[0][0] :,
self.cropping[1][0] : -self.cropping[1][1],
]
elif self.cropping[1][1] == 0:
return inputs[
:,View on GitHub (pinned to 7a34a03db6)
When it happens
Trigger: Thrown at keras/src/layers/reshaping/cropping2d.py:154 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/5333b74cf634e2aa.
Report an issue: GitHub.