freeze_layers#

composer.functional.freeze_layers(model, optimizers, current_duration, freeze_start=0.5, freeze_level=1.0)[source]#

Progressively freeze the layers of the network in-place during training, starting with the earlier layers.

Example

from composer.algorithms.layer_freezing import freeze_layers
freeze_depth, feeze_level = freeze_layers(
                                model=model,
                                optimizers=optimizer,
                                current_duration=0.5,
                                freeze_start=0.0,
                                freeze_level=1.0
                            )
Parameters
  • model (Module) โ€“ The model being trained.

  • optimizers (Optimizer | Sequence[Optimizer]) โ€“ The optimizers used during training.

  • current_duration (float) โ€“ The fraction, in [0, 1) of the training process complete.

  • freeze_start (float, optional) โ€“ The fraction of the training process in [0, 1) to run before freezing begins. Default: 0.5.

  • freeze_level (float, optional) โ€“ The maximum fraction of layers on [0, 1) to freeze. Default: 1.0.

Returns

The number of layers frozen, and the percentage of the total model frozen.

Return type

(int, float)