fusionlab.encoders.convnext.convnext module#
Ref: facebookresearch/ConvNeXt Ref: pytorch/vision
- class fusionlab.encoders.convnext.convnext.Block(dim, drop_path=0.0, layer_scale_init_value=1e-06, spatial_dims=2)[source]#
Bases:
ModuleConvNeXt Block. There are two equivalent implementations: (1) DwConv -> LayerNorm (channels_first) -> 1x1 Conv -> GELU -> 1x1 Conv; all in (N, C, H, W) (2) DwConv -> Permute to (N, H, W, C); LayerNorm (channels_last) -> Linear -> GELU -> Linear; Permute back We use (2) as we find it slightly faster in PyTorch
- Parameters:
dim (int) – Number of input channels.
drop_path (float) – Stochastic depth rate. Default: 0.0
layer_scale_init_value (float) – Init value for Layer Scale. Default: 1e-6.
- forward(x)[source]#
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- training: bool#
- class fusionlab.encoders.convnext.convnext.ConvNeXt(in_chans=3, depths=[3, 3, 9, 3], dims=[96, 192, 384, 768], drop_path_rate=0.0, layer_scale_init_value=1e-06, spatial_dims=2)[source]#
Bases:
Module- A PyTorch impl ofA ConvNet for the 2020s -
- Parameters:
in_chans (int) – Number of input image channels. Default: 3
num_classes (int) – Number of classes for classification head. Default: 1000
depths (tuple(int)) – Number of blocks at each stage. Default: [3, 3, 9, 3]
dims (int) – Feature dimension at each stage. Default: [96, 192, 384, 768]
drop_path_rate (float) – Stochastic depth rate. Default: 0.
layer_scale_init_value (float) – Init value for Layer Scale. Default: 1e-6.
head_init_scale (float) – Init scaling value for classifier weights and biases. Default: 1.
- forward(x)[source]#
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- training: bool#
- class fusionlab.encoders.convnext.convnext.ConvNeXtBase(cin=3, spatial_dims=2)[source]#
Bases:
ConvNeXt- training: bool#
- class fusionlab.encoders.convnext.convnext.ConvNeXtLarge(cin=3, spatial_dims=2)[source]#
Bases:
ConvNeXt- training: bool#
- class fusionlab.encoders.convnext.convnext.ConvNeXtSmall(cin=3, spatial_dims=2)[source]#
Bases:
ConvNeXt- training: bool#
- class fusionlab.encoders.convnext.convnext.ConvNeXtTiny(cin=3, spatial_dims=2)[source]#
Bases:
ConvNeXt- training: bool#
- class fusionlab.encoders.convnext.convnext.ConvNeXtXLarge(cin=3, spatial_dims=2)[source]#
Bases:
ConvNeXt- training: bool#
- class fusionlab.encoders.convnext.convnext.LayerNorm(normalized_shape, eps=1e-06, data_format='channels_last')[source]#
Bases:
ModuleLayerNorm that supports two data formats: channels_last (default) or channels_first. The ordering of the dimensions in the inputs. channels_last corresponds to inputs with shape (batch_size, height, width, channels) while channels_first corresponds to inputs with shape (N, C, H, W).
- forward(x)[source]#
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- training: bool#