{"record":{"id":"0adfa0e9b51ceb32","repo":"keras-team/keras","slug":"cropping-parameter-of-cropping1d-layer-must-be-0adfa0","errorCode":null,"errorMessage":"`cropping` parameter of `Cropping1D` layer must be smaller than the input length. Received: inputs.shape={inputs.shape}, cropping={self.cropping}","messagePattern":"`cropping` parameter of `Cropping1D` layer must be smaller than the input length\\. Received: inputs\\.shape=(.+?), cropping=(.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/reshaping/cropping1d.py","lineNumber":69,"sourceCode":"    def compute_output_shape(self, input_shape):\n        if input_shape[1] is not None:\n            length = input_shape[1] - self.cropping[0] - self.cropping[1]\n            if length <= 0:\n                raise ValueError(\n                    \"`cropping` parameter of `Cropping1D` layer must be \"\n                    \"smaller than the input length. Received: input_shape=\"\n                    f\"{input_shape}, cropping={self.cropping}\"\n                )\n        else:\n            length = None\n        return (input_shape[0], length, input_shape[2])\n\n    def call(self, inputs):\n        if (\n            inputs.shape[1] is not None\n            and sum(self.cropping) >= inputs.shape[1]\n        ):\n            raise ValueError(\n                \"`cropping` parameter of `Cropping1D` layer must be \"\n                \"smaller than the input length. Received: inputs.shape=\"\n                f\"{inputs.shape}, cropping={self.cropping}\"\n            )\n        if self.cropping[1] == 0:\n            return inputs[:, self.cropping[0] :, :]\n        else:\n            return inputs[:, self.cropping[0] : -self.cropping[1], :]\n\n    def get_config(self):\n        config = {\"cropping\": self.cropping}\n        base_config = super().get_config()\n        return {**base_config, **config}\n","sourceCodeStart":51,"sourceCodeEnd":83,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/reshaping/cropping1d.py#L51-L83","documentation":"Raised by Cropping1D.call at execution time: the sum of the two crop amounts is >= the temporal dimension of the actual input tensor (inputs.shape), so the cropped axis would be empty or negative. This is the runtime counterpart of the compute_output_shape check and fires when shapes were unknown at build time.","triggerScenarios":"Thrown at keras/src/layers/reshaping/cropping1d.py:69 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Lower the cropping so the sum of both ends is smaller than the sequence length of the data actually fed to the layer","Check that the input tensor really has the temporal size you assume (e.g. after an upstream layer changed it)","Use dynamic shapes carefully: validate crop sizes against runtime sequence length"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}