TensorFlow 2.0 Beta is available Learn more

tfmot.sparsity.keras.ConstantSparsity

Class ConstantSparsity

Pruning schedule with constant sparsity(%) throughout training.

Inherits From: PruningSchedule

Defined in python/core/sparsity/keras/pruning_schedule.py.

__init__

__init__(
    target_sparsity,
    begin_step,
    end_step=-1,
    frequency=100
)

Initializes a Pruning schedule with constant sparsity.

Sparsity is applied in the interval [begin_step, end_step] every frequency steps. At each applicable step, the sparsity(%) is constant.

Args:

  • target_sparsity: A scalar float representing the target sparsity value.
  • begin_step: Step at which to begin pruning.
  • end_step: Step at which to end pruning. -1 by default. -1 implies continuing to prune till the end of training.
  • frequency: Only apply pruning every frequency steps.

Methods

__call__

__call__(step)

from_config

from_config(
    cls,
    config
)

Instantiates a PruningSchedule from its config.

Args:

  • config: Output of get_config().

Returns:

A PruningSchedule instance.

get_config

get_config()