This question evaluates proficiency in PyTorch model implementation, convolutional output shape arithmetic, channel configuration, and debugging of U-Net-style segmentation networks with valid (no-padding) convolutions.
You are given a PyTorch implementation of a U-Net-like segmentation model that should follow the original U-Net style with valid convolutions (no padding).
A unit test is failing due to shape mismatches and an incorrect output channel count.
2
is the number of segmentation classes.
Fix the U-Net implementation by editing only a few scalar values/flags (no redesign). The buggy areas are:
num_classes
setting.
(B, 1, 572, 572)
runs without errors and returns a tensor of shape
(B, 2, 388, 388)
.
B>=1
.
(You do not need to write training code.)