{"record":{"id":"da1e2a090dadb2be","repo":"keras-team/keras","slug":"the-argument-strides-cannot-contains-0-s-recei","errorCode":null,"errorMessage":"The argument `strides` cannot contains 0(s). Received: strides={self.strides}","messagePattern":"The argument `strides` cannot contains 0\\(s\\)\\. Received: strides=(.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/convolutional/base_separable_conv.py","lineNumber":154,"sourceCode":"                \"Invalid value for argument `depth_multiplier`. Expected a \"\n                \"strictly positive value. Received \"\n                f\"depth_multiplier={self.depth_multiplier}.\"\n            )\n\n        if self.filters is not None and self.filters <= 0:\n            raise ValueError(\n                \"Invalid value for argument `filters`. Expected a strictly \"\n                f\"positive value. Received filters={self.filters}.\"\n            )\n\n        if not all(self.kernel_size):\n            raise ValueError(\n                \"The argument `kernel_size` cannot contain 0. Received: \"\n                f\"kernel_size={self.kernel_size}.\"\n            )\n\n        if not all(self.strides):\n            raise ValueError(\n                \"The argument `strides` cannot contains 0(s). Received: \"\n                f\"strides={self.strides}\"\n            )\n\n    def build(self, input_shape):\n        if self.data_format == \"channels_last\":\n            channel_axis = -1\n            input_channel = input_shape[-1]\n        else:\n            channel_axis = 1\n            input_channel = input_shape[1]\n        self.input_spec = InputSpec(\n            min_ndim=self.rank + 2, axes={channel_axis: input_channel}\n        )\n        depthwise_kernel_shape = self.kernel_size + (\n            input_channel,\n            self.depth_multiplier,\n        )","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/convolutional/base_separable_conv.py#L136-L172","documentation":"Separable convolution strides must be positive in every spatial dimension; a 0 stride cannot slide the filter. __init__ rejects any strides sequence containing 0 (the message contains the typo 'cannot contains').","triggerScenarios":"Constructing SeparableConv1D/2D with a strides tuple containing 0, often from a computed downsampling factor or a mis-pasted tuple.","commonSituations":"Strides derived from input-size arithmetic that underflows to 0; reusing a kernel_size tuple as strides by mistake.","solutions":["Set strides to positive integers (default 1).","Validate dynamic strides: all(s > 0 for s in strides).","Prefer strides=1 with pooling layers when unsure."],"exampleFix":"# before\nkeras.layers.SeparableConv2D(32, 3, strides=(0, 2))\n\n# after\nkeras.layers.SeparableConv2D(32, 3, strides=(2, 2))","handlingStrategy":"validation","validationCode":"st = strides if isinstance(strides, (tuple, list)) else (strides,)\nassert all(s > 0 for s in st)","typeGuard":"def valid_strides(strides) -> bool:\n    st = strides if isinstance(strides, (tuple, list)) else (strides,)\n    return all(s > 0 for s in st)","tryCatchPattern":null,"preventionTips":["Default to strides=1 unless downsampling is intended","Never let computed strides reach 0"],"tags":["keras","separable-conv","strides","invalid-arguments"],"backgroundTag":"invalid-layer-argument-value","analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}