Concept

Feature Extraction in Fully Convolutional Networks

When utilizing a pretrained convolutional neural network, such as ResNet-18, for feature extraction in a Fully Convolutional Network (FCN), the final classification layers must be removed. Specifically, the global average pooling layer and the fully connected layer are discarded because they collapse spatial dimensions and are unnecessary for dense pixel-level predictions. The remaining layers form the feature extraction backbone of the FCN, which produces feature maps with reduced spatial dimensions. For example, given an input with a height of 320320 and width of 480480, the forward propagation reduces the spatial dimensions by a factor of 1/321/32, resulting in an output shape of 10×1510 \times 15. This extraction process can be implemented in frameworks like PyTorch or MXNet by explicitly selecting all layers except the final pooling and dense layers.

# PyTorch net = nn.Sequential(*list(pretrained_net.children())[:-2])
# MXNet net = nn.HybridSequential() for layer in pretrained_net.features[:-2]: net.add(layer)

0

1

Updated 2026-05-21

Contributors are:

Who are from:

Tags

D2L

Dive into Deep Learning @ D2L