- composer.functional.apply_blurpool(model, replace_convs=True, replace_maxpools=True, blur_first=True, min_channels=16, optimizers=None)#
These filters increase invariance to small spatial shifts in the input (Zhang 2019).
torch.nn.Module) – the model to modify in-place
blur_first (bool, optional) – for
replace_convs, blur input before the associated convolution. When set to
False, the convolution is applied with a stride of 1 before the blurring, resulting in significant overhead (though more closely matching the paper). See
BlurConv2dfor further discussion. Default:
min_channels (int, optional) – Skip replacing layers with in_channels < min_channels. Commonly used to prevent the blurring of the first layer. Default: 16.
Existing optimizers bound to
model.parameters(). All optimizers that have already been constructed with
model.parameters()must be specified here so they will optimize the correct parameters.
If the optimizer(s) are constructed after calling this function, then it is safe to omit this parameter. These optimizers will see the correct model parameters.
The modified model
import composer.functional as cf from torchvision import models model = models.resnet50() cf.apply_blurpool(model)