tensorflow/models · error · ValueError

Activation not supported by…

Error message

Activation {} not supported by Default8BitActivationQuantizeConfig.

What it means

Guard in Default8BitActivationQuantizeConfig.get_output_quantizers: it decides whether to quantize the activation output based on layer.activation.__name__; if the activation callable has no __name__ (e.g. a callable object or partial), the config cannot classify it and raises this ValueError.

Solutions

  1. Use a named activation function (e.g. tf.nn.relu) instead of a callable object
  2. Wrap custom activations in a supported named function
  3. Extend the config's supported-activation list for the new activation
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at official/projects/qat/nlp/quantization/configs.py:259 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of tensorflow/models@e006f5f0d5 (2026-08-24). Data as JSON: /api/errors/556d27cc5d7b906f. Report an issue: GitHub.

Appendix: source

Thrown at official/projects/qat/nlp/quantization/configs.py:259

      self,
      layer: Layer,
      quantize_weights: Sequence[tf.Tensor]):
    """See base class."""
    self._assert_activation_layer(layer)

  def set_quantize_activations(
      self,
      layer: Layer,
      quantize_activations: Sequence[Activation]):
    """See base class."""
    self._assert_activation_layer(layer)

  def get_output_quantizers(self, layer: Layer) -> Sequence[Quantizer]:
    """See base class."""
    self._assert_activation_layer(layer)

    if not hasattr(layer.activation, '__name__'):
      raise ValueError('Activation {} not supported by '
                       'Default8BitActivationQuantizeConfig.'.format(
                           layer.activation))

    # This code is copied from TFMOT repo, but added relu6 to support mobilenet.
    if layer.activation.__name__ in ['relu', 'relu6']:
      # 'relu' should generally get fused into the previous layer.
      return [MovingAverageQuantizer(
          num_bits=8, per_axis=False, symmetric=False, narrow_range=False)]
    elif layer.activation.__name__ in ['linear', 'softmax', 'sigmoid']:
      return []

    raise ValueError('Activation {} not supported by '
                     'Default8BitActivationQuantizeConfig.'.format(
                         layer.activation))

  def get_config(self) -> Dict[str, Any]:
    """Get a config for this quantizer config."""
    return {}

View on GitHub (pinned to e006f5f0d5)