LayerFreezing#

class composer.algorithms.LayerFreezing(freeze_start=0.5, freeze_level=1.0)[source]#

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

Freezing starts after the fraction of training specified by freeze_start has elapsed. The fraction of layers frozen increases linearly until it reaches freeze_level at the end of training.

This freezing schedule is most similar to FreezeOut and Freeze Training.

Runs on Event.EPOCH_END.

Example

from composer.algorithms import LayerFreezing
from composer.trainer import Trainer
layer_freezing_algorithm = LayerFreezing(
    freeze_start=0.0,
    freeze_level=1.0
)
trainer = Trainer(
    model=model,
    train_dataloader=train_dataloader,
    eval_dataloader=eval_dataloader,
    max_duration="1ep",
    algorithms=[layer_freezing_algorithm],
    optimizers=[optimizer]
)
Parameters
  • freeze_start (float) โ€“ The fraction of training to run before freezing begins. Default: 0.5.

  • freeze_level (float) โ€“ The maximum fraction of layers to freeze. Default: 1.0.

property find_unused_parameters#

Override in order to tell DDP that some parameters will not have gradients computed for them after layer freezing is applied.