{"record":{"id":"ed16c025718fc0cf","repo":"keras-team/keras","slug":"invalid-value-for-argument-filters-expected-a-s","errorCode":null,"errorMessage":"Invalid value for argument `filters`. Expected a strictly positive value. Received filters={self.filters}.","messagePattern":"Invalid value for argument `filters`\\. Expected a strictly positive value\\. Received filters=(.+?)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/convolutional/base_separable_conv.py","lineNumber":142,"sourceCode":"        self.depthwise_regularizer = regularizers.get(depthwise_regularizer)\n        self.pointwise_regularizer = regularizers.get(pointwise_regularizer)\n        self.bias_regularizer = regularizers.get(bias_regularizer)\n        self.depthwise_constraint = constraints.get(depthwise_constraint)\n        self.pointwise_constraint = constraints.get(pointwise_constraint)\n        self.bias_constraint = constraints.get(bias_constraint)\n        self.data_format = self.data_format\n\n        self.input_spec = InputSpec(min_ndim=self.rank + 2)\n\n        if self.depth_multiplier is not None and self.depth_multiplier <= 0:\n            raise ValueError(\n                \"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\":","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/convolutional/base_separable_conv.py#L124-L160","documentation":"Separable convolutions require filters (number of output channels) to be strictly positive. The pointwise stage must produce at least one channel, so __init__ rejects filters <= 0.","triggerScenarios":"Constructing SeparableConv1D/2D with filters=0 or negative, e.g. when filters is computed from a width multiplier (filters = base * alpha) that truncates to 0.","commonSituations":"EfficientNet/MobileNet-style width-multiplier code where alpha < 1/filter_base truncates to 0; config parsing that loses the filters value.","solutions":["Set filters to a positive integer (e.g. max(1, int(base * alpha))).","Validate before construction: isinstance(filters, int) and filters > 0.","Check hyperparameter sweep ranges for 0/negative filter counts."],"exampleFix":"# before\nfilters = int(32 * alpha)  # alpha small -> 0\nkeras.layers.SeparableConv2D(filters, 3)\n\n# after\nfilters = max(1, int(round(32 * alpha)))\nkeras.layers.SeparableConv2D(filters, 3)","handlingStrategy":"validation","validationCode":"filters = max(1, int(round(base * alpha)))\nassert isinstance(filters, int) and filters > 0","typeGuard":"def valid_filters(filters) -> bool:\n    return isinstance(filters, int) and filters > 0","tryCatchPattern":null,"preventionTips":["Clamp width-multiplier arithmetic to >= 1","Validate sweep bounds for filter counts"],"tags":["keras","separable-conv","filters","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"}