{"record":{"id":"bfb62b41fcecefe1","repo":"keras-team/keras","slug":"invalid-value-for-argument-depth-multiplier-exp","errorCode":null,"errorMessage":"Invalid value for argument `depth_multiplier`. Expected a strictly positive value. Received depth_multiplier={self.depth_multiplier}.","messagePattern":"Invalid value for argument `depth_multiplier`\\. Expected a strictly positive value\\. Received depth_multiplier=(.+?)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/convolutional/base_depthwise_conv.py","lineNumber":132,"sourceCode":"        self.strides = standardize_tuple(strides, rank, \"strides\")\n        self.dilation_rate = standardize_tuple(\n            dilation_rate, rank, \"dilation_rate\"\n        )\n        self.padding = standardize_padding(padding)\n        self.data_format = standardize_data_format(data_format)\n        self.activation = activations.get(activation)\n        self.use_bias = use_bias\n        self.depthwise_initializer = initializers.get(depthwise_initializer)\n        self.bias_initializer = initializers.get(bias_initializer)\n        self.depthwise_regularizer = regularizers.get(depthwise_regularizer)\n        self.bias_regularizer = regularizers.get(bias_regularizer)\n        self.depthwise_constraint = constraints.get(depthwise_constraint)\n        self.bias_constraint = constraints.get(bias_constraint)\n        self.input_spec = InputSpec(min_ndim=self.rank + 2)\n        self.data_format = self.data_format\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 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. Received \"\n                f\"strides={self.strides}\"\n            )\n\n    def build(self, input_shape):","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/convolutional/base_depthwise_conv.py#L114-L150","documentation":"Depthwise convolution layers require depth_multiplier to be strictly positive; zero or negative values would produce zero output channels. __init__ of DepthwiseConv1D/2D/3D validates this immediately.","triggerScenarios":"Passing depth_multiplier=0 or a negative value (often computed from config or a sweep) when constructing keras.layers.DepthwiseConv2D or 1D/3D variants.","commonSituations":"Hyperparameter search yielding 0; depth_multiplier computed from a channel count or ratio that underflows to 0; copy-paste from a SeparableConv config.","solutions":["Set depth_multiplier to a positive integer (typically 1).","Clamp computed values: max(1, int(value)).","Check the config/sweep bounds producing the value."],"exampleFix":"# before\nlayer = keras.layers.DepthwiseConv2D(3, depth_multiplier=0)\n\n# after\nlayer = keras.layers.DepthwiseConv2D(3, depth_multiplier=1)","handlingStrategy":"validation","validationCode":"assert depth_multiplier is None or (isinstance(depth_multiplier, int) and depth_multiplier > 0)","typeGuard":"def valid_depth_multiplier(dm) -> bool:\n    return dm is None or (isinstance(dm, int) and dm > 0)","tryCatchPattern":null,"preventionTips":["Validate config values before building models","Clamp computed multipliers to max(1, dm)"],"tags":["keras","depthwise-conv","invalid-arguments","validation"],"backgroundTag":"invalid-layer-argument-value","analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}