{"record":{"id":"2a0da6ad00086f1e","repo":"tensorflow/models","slug":"number-of-output-filters-must-be-even-to-ensure-sp","errorCode":null,"errorMessage":"Number of output filters must be even to ensure splitting in channel dimension for reversible blocks","messagePattern":"Number of output filters must be even to ensure splitting in channel dimension for reversible blocks","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/vision/modeling/backbones/revnet.py","lineNumber":125,"sourceCode":"    x = self._norm(\n        axis=axis,\n        momentum=norm_momentum,\n        epsilon=norm_epsilon,\n        synchronized=use_sync_bn)(x)\n    x = tf_utils.get_activation(activation)(x)\n    x = tf_keras.layers.MaxPool2D(pool_size=3, strides=2, padding='same')(x)\n\n    endpoints = {}\n    for i, spec in enumerate(REVNET_SPECS[model_id]):\n      if spec[0] == 'residual':\n        inner_block_fn = nn_blocks.ResidualInner\n      elif spec[0] == 'bottleneck':\n        inner_block_fn = nn_blocks.BottleneckResidualInner\n      else:\n        raise ValueError('Block fn `{}` is not supported.'.format(spec[0]))\n\n      if spec[1] % 2 != 0:\n        raise ValueError('Number of output filters must be even to ensure '\n                         'splitting in channel dimension for reversible blocks')\n\n      x = self._block_group(\n          inputs=x,\n          filters=spec[1],\n          strides=(1 if i == 0 else 2),\n          inner_block_fn=inner_block_fn,\n          block_repeats=spec[2],\n          batch_norm_first=(i != 0),  # Only skip on first block\n          name='revblock_group_{}'.format(i + 2))\n      endpoints[str(i + 2)] = x\n\n    self._output_specs = {l: endpoints[l].get_shape() for l in endpoints}\n\n    super(RevNet, self).__init__(inputs=inputs, outputs=endpoints, **kwargs)\n\n  def _block_group(self,\n                   inputs: tf.Tensor,","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/vision/modeling/backbones/revnet.py#L107-L143","documentation":"Raised in RevNet __init__ when the number of output filters is odd; reversible blocks split the channels in half, requiring an even count.","triggerScenarios":"Thrown at official/vision/modeling/backbones/revnet.py:125 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set the stage's filters to an even number so channels can be split for the reversible block.","Halve an odd filter count or round it to the nearest even value in the backbone config."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}