Train for 'n' output channels and test it on 'n-1' output channels in Neural network

I trained a Convolutional Neural Network with U-Net architecture for a regression problem. I have 20 output channels. After training, I would like to use the trained weights to test it on a dataset with 19 output channels. Is it possible?

Basically, I’m trying to check the output r^2 value of my model if I avoided different output channels. For that, I would like to train the network with all the 20 output channels and then use that inference for the same data set with 19 output channels or 18 output channels up to 1 output channel so that I can note down the effect of different channels r^2.

Would you like to change the output channels of the last conv layer only?
If so, then you could manipulate the filters (and bias) directly via:

with torch.no_grad():
    model.last_conv.weight = nn.Parameter(model.last_conv.weight[:-1])
    ...

or any other operation besides the slicing.

Manipulating intermediate conv layers would be a bit more tricky, since you would also have to change the in_channels of the successive conv layer.