{"record":{"id":"aa03de413fd3e89d","repo":"tensorflow/models","slug":"number-of-input-channels-input-shape-1-are-no","errorCode":null,"errorMessage":"Number of input channels: {input_shape[-1]} are not divisible by number of groups: {self._groups}.","messagePattern":"Number of input channels: (.+?) are not divisible by number of groups: (.+?)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/projects/edgetpu/vision/modeling/custom_layers.py","lineNumber":353,"sourceCode":"      raise ValueError('Valid padding options are : same, or valid.')\n\n    self._groups = groups\n    for _ in range(self._groups):\n      # Override the activation so that batchnorm can be applied after the conv.\n      self.conv_layers.append(\n          tf_keras.layers.Conv2D(per_conv_filter_size, kernel_size, **kwargs))\n\n    if self.use_batch_norm:\n      for _ in range(self._groups):\n        self.bn_layers.append(\n            self.batch_norm_layer(  # pyrefly: ignore[not-callable]\n                axis=-1, momentum=bn_momentum, epsilon=bn_epsilon))  # pytype: disable=bad-return-type  # typed-keras\n\n  def call(self, inputs: Any) -> Any:  # pytype: disable=signature-mismatch  # overriding-parameter-count-checks\n    \"\"\"Applies 2d group convolution on the inputs.\"\"\"\n    input_shape = inputs.get_shape().as_list()\n    if input_shape[-1] % self._groups != 0:\n      raise ValueError(\n          f'Number of input channels: {input_shape[-1]} are not divisible '\n          f'by number of groups: {self._groups}.')\n    input_slices = tf.split(inputs, num_or_size_splits=self._groups, axis=-1)\n    output_slices = []\n    for g in range(self._groups):\n      output_slice = self.conv_layers[g](input_slices[g])\n      if self.use_batch_norm:\n        output_slice = self.bn_layers[g](output_slice)\n      output_slice = self.activation(output_slice)  # pyrefly: ignore[not-callable]\n      output_slices.append(output_slice)\n\n    outputs = tf.concat(output_slices, axis=-1)\n    return outputs\n\n\ndef _nnapi_scalar(value, dtype):\n  # Resolves \"Scalar operand should be constant\" at cost of broadcasting\n  return tf.constant(value, dtype=dtype, shape=(1,))","sourceCodeStart":335,"sourceCodeEnd":371,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/projects/edgetpu/vision/modeling/custom_layers.py#L335-L371","documentation":"Error \"Number of input channels: {input_shape[-1]} are not divisible by number of groups: {self._groups}.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/projects/edgetpu/vision/modeling/custom_layers.py:353 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}