composer.algorithms.stochastic_depth.stochastic_layers#
Stochastic forward functions for ResNet Bottleneck modules.
Functions
Model surgery policy that dictates how to convert a ResNet Bottleneck layer into a stochastic version. |
Classes
A convenience class that stochastically executes the provided main path of a residual block. |
- class composer.algorithms.stochastic_depth.stochastic_layers.BlockStochasticModule(main, residual=None, drop_rate=0.2)[source]#
Bases:
torch.nn.modules.module.Module
A convenience class that stochastically executes the provided main path of a residual block.
- Parameters
main (GraphModule) โ Operators in the main (non-residual) path of a residual block.
residual (GraphModule | None) โ Operators, if any, in the residual path of a residual block.
drop_rate โ The base probability of dropping this layer. Must be between 0.0 (inclusive) and 1.0 (inclusive).
- Returns
BlockStochasticModule โ An instance of
BlockStochasticModule
.
- composer.algorithms.stochastic_depth.stochastic_layers.block_stochastic_forward(self, x)[source]#
ResNet Bottleneck forward function where the layers are randomly skipped with probability
drop_rate
during training.