An up block is the expansive-path component of a U-Net that increases feature-map resolution. It uses a 2D transposed convolution to upsample features, fill spatial gaps, and produce larger outputs than its input. section 6.2.3 section 6.3.1
Trace an up block through its main operations:
- Receive the current feature representation and a skip-connection feature from the contracting path. section 6.3.1
- Concatenate the current representation with the skip feature along the channel dimension. section 6.3.1
- Apply ConvTranspose2d; its kernel and stride control how much spatial resolution increases. section 6.2.3 section 6.3.1
- Refine the enlarged features with two residual convolutional blocks. section 6.3.1
A hand-worked transposed convolution
A 2 × 2 input with values [[0, 1], [1, 2]] passes through a one-channel ConvTranspose2d layer with a 2 × 2 kernel and stride 2. With weights [[1, 2], [2, 3]] and zero bias, the output becomes a 4 × 4 feature map, demonstrating how learned kernels expand resolution and fill gaps. section 6.2.3
class UnetUp(nn.Module):
def __init__(self, in_channels, out_channels):
super().__init__()
layers = [nn.ConvTranspose2d(in_channels,
out_channels, 2, 2),
ResidualConvBlock(out_channels, out_channels),
ResidualConvBlock(out_channels,
out_channels),] #1
self.model = nn.Sequential(*layers)
def forward(self, x, skip):
x = torch.cat((x, skip), 1)
x = self.model(x)
return x
Inspect the compact PyTorch UnetUp implementation, including skip-feature concatenation, ConvTranspose2d, and residual convolutional refinement. section 6.3.1
