EfficientNetEncoder¶
- class EfficientNetEncoder[source]¶
EfficientNetB0 encoder for feature extraction.
This encoder extracts multi-scale features from input images using EfficientNetB0 architecture. It consists of a stem convolution followed by multiple MBConv blocks organized into stages.
- _conv_stem¶
Initial stem convolution layer.
- Type:
- _bn0¶
Batch normalization after stem convolution.
- Type:
nn.BatchNorm2d
- _swish¶
SiLU activation function.
- Type:
SiLU
- _blocks¶
List of MBConv blocks.
- Type:
nn.ModuleList
- _conv_head¶
Head convolution layer.
- Type:
- _bn1¶
Batch normalization after head convolution.
- Type:
nn.BatchNorm2d
- _avg_pooling¶
Global average pooling layer.
- Type:
nn.AdaptiveAvgPool2d
- _dropout¶
Dropout layer.
- Type:
nn.Dropout
Example
>>> encoder = EfficientNetEncoder() >>> x = torch.randn(1, 3, 224, 224) >>> features = encoder(x) >>> len(features) ... 5 >>> [f.shape for f in features] ... [torch.Size([1, 32, 112, 112]), torch.Size([1, 24, 56, 56]), ... torch.Size([1, 40, 28, 28]), torch.Size([1, 80, 14, 14]), ... torch.Size([1, 112, 14, 14])]
Initialize EfficientNetEncoder.
Sets up the EfficientNetB0 encoder with stem, MBConv blocks, and head.
Methods
Forward pass through EfficientNet encoder.
Attributes
training- forward(x)[source]¶
Forward pass through EfficientNet encoder.
Extracts multi-scale features from input image at different stages of the encoder network.
- Parameters:
x (torch.Tensor) – (B, 3, H, W). Input image tensor.
self (EfficientNetEncoder)
- Returns:
List of feature maps at different scales. - features[0]: (B, 32, H/2, W/2) - features[1]: (B, 24, H/4, W/4) - features[2]: (B, 40, H/8, W/8) - features[3]: (B, 112, H/16, W/16) - features[4]: (B, 320, H/32, W/32)
- Return type: