tfmot.sparsity.keras.ConstantSparsity

Pruning schedule with constant sparsity(%) throughout training.

Inherits From: PruningSchedule

Used in the notebooks

Used in the guide

target_sparsityA scalar float representing the target sparsity value.
begin_stepStep at which to begin pruning.
end_stepStep at which to end pruning. -1 by default. -1 implies continuing to prune till the end of training.
frequencyOnly apply pruning every frequency steps.

Methods

from_config

View source

Instantiates a PruningSchedule from its config.

Args
configOutput of get_config().

Returns
A PruningSchedule instance.

get_config

View source

__call__

View source

Returns the sparsity(%) to be applied.

If the returned sparsity(%) is 0, pruning is ignored for the step.

Args
stepCurrent step in graph execution.

Returns
Sparsity (%) that should be applied to the weights for the step.