Encoders#

PyTorch Encoders#

AlexNet#

class fusionlab.encoders.AlexNet(cin=3, spatial_dims=2)[source]#
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 Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Return type:

Tensor

VGG#

class fusionlab.encoders.VGG16(cin=3, spatial_dims=2)[source]#
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 Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class fusionlab.encoders.VGG19(cin=3, spatial_dims=2)[source]#
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 Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

InceptionNet#

class fusionlab.encoders.InceptionNetV1(cin=3, spatial_dims=2)[source]#
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 Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

ResNet#

class fusionlab.encoders.ResNet(block, layers, zero_init_residual=False, groups=1, width_per_group=64, replace_stride_with_dilation=None, norm_layer=None, cin=3, spatial_dims=2)[source]#
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 Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Return type:

Tensor

class fusionlab.encoders.ResNet18(cin=3, spatial_dims=2)[source]#
class fusionlab.encoders.ResNet34(cin=3, spatial_dims=2)[source]#
class fusionlab.encoders.ResNet50(cin=3, spatial_dims=2)[source]#
class fusionlab.encoders.ResNet101(cin=3, spatial_dims=2)[source]#
class fusionlab.encoders.ResNet152(cin=3, spatial_dims=2)[source]#

EfficientNet#

class fusionlab.encoders.EfficientNet(inverted_residual_setting, cin=3, stochastic_depth_prob=0.2, last_channel=None, norm_layer=None, spatial_dims=2)[source]#
__init__(inverted_residual_setting, cin=3, stochastic_depth_prob=0.2, last_channel=None, norm_layer=None, spatial_dims=2)[source]#

EfficientNet V1 and V2 main class

Parameters:
  • inverted_residual_setting (Sequence[Union[MBConvConfig, FusedMBConvConfig]]) – Network structure

  • dropout (float) – The droupout probability

  • stochastic_depth_prob (float) – The stochastic depth probability

  • num_classes (int) – Number of classes

  • norm_layer (Optional[Callable[..., nn.Module]]) – Module specifying the normalization layer to use

  • last_channel (int) – The number of channels on the penultimate layer

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 Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Return type:

Tensor

class fusionlab.encoders.EfficientNetB0(cin=3, spatial_dims=2)[source]#
class fusionlab.encoders.EfficientNetB1(cin=3, spatial_dims=2)[source]#
class fusionlab.encoders.EfficientNetB2(cin=3, spatial_dims=2)[source]#
class fusionlab.encoders.EfficientNetB3(cin=3, spatial_dims=2)[source]#
class fusionlab.encoders.EfficientNetB4(cin=3, spatial_dims=2)[source]#
class fusionlab.encoders.EfficientNetB5(cin=3, spatial_dims=2)[source]#
class fusionlab.encoders.EfficientNetB6(cin=3, spatial_dims=2)[source]#
class fusionlab.encoders.EfficientNetB7(cin=3, spatial_dims=2)[source]#

ConvNeXt#

class fusionlab.encoders.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]#
A PyTorch impl ofA ConvNet for the 2020s -

https://arxiv.org/pdf/2201.03545.pdf

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 Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class fusionlab.encoders.ConvNeXtTiny(cin=3, spatial_dims=2)[source]#
class fusionlab.encoders.ConvNeXtSmall(cin=3, spatial_dims=2)[source]#
class fusionlab.encoders.ConvNeXtBase(cin=3, spatial_dims=2)[source]#
class fusionlab.encoders.ConvNeXtLarge(cin=3, spatial_dims=2)[source]#
class fusionlab.encoders.ConvNeXtXLarge(cin=3, spatial_dims=2)[source]#