tensorflow/models · error · NotImplementedError

Only PolynomialDecay and ConstantSparsity are currently…

Error message

Only PolynomialDecay and ConstantSparsity are currently supported. Not support %s

What it means

Dispatch guard in the pruning task's build_model: only the tfmot 'PolynomialDecay' and 'ConstantSparsity' pruning schedules are wired up; any other pruning_cfg.pruning_schedule string falls through both branches and raises this ValueError.

Solutions

  1. Set pruning_schedule to 'PolynomialDecay' or 'ConstantSparsity'
  2. Fix the config value/typo for the schedule name
  3. Add a branch constructing the desired tfmot schedule
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at official/projects/pruning/tasks/image_classification.py:89 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/3d3df7f334399074. Report an issue: GitHub.

Appendix: source

Thrown at official/projects/pruning/tasks/image_classification.py:89

    pruning_params = {}
    if pruning_cfg.sparsity_m_by_n is not None:
      pruning_params['sparsity_m_by_n'] = pruning_cfg.sparsity_m_by_n

    if pruning_cfg.pruning_schedule == 'PolynomialDecay':
      pruning_params['pruning_schedule'] = tfmot.sparsity.keras.PolynomialDecay(
          initial_sparsity=pruning_cfg.initial_sparsity,
          final_sparsity=pruning_cfg.final_sparsity,
          begin_step=pruning_cfg.begin_step,
          end_step=pruning_cfg.end_step,
          frequency=pruning_cfg.frequency)
    elif pruning_cfg.pruning_schedule == 'ConstantSparsity':
      pruning_params[
          'pruning_schedule'] = tfmot.sparsity.keras.ConstantSparsity(
              target_sparsity=pruning_cfg.final_sparsity,
              begin_step=pruning_cfg.begin_step,
              frequency=pruning_cfg.frequency)
    else:
      raise NotImplementedError(
          'Only PolynomialDecay and ConstantSparsity are currently supported. Not support %s'
          % pruning_cfg.pruning_schedule)

    pruned_model = tfmot.sparsity.keras.prune_low_magnitude(
        prunable_model, **pruning_params)

    # Print out prunable weights for debugging purpose.
    prunable_layers = collect_prunable_layers(pruned_model)
    pruned_weights = []
    for layer in prunable_layers:
      pruned_weights += [weight.name for weight, _, _ in layer.pruning_vars]
    unpruned_weights = [
        weight.name
        for weight in pruned_model.weights
        if weight.name not in pruned_weights
    ]

    logging.info(

View on GitHub (pinned to e006f5f0d5)