From nn.Upsample to F.interpolate

(Peter Dekkers) #1

I noticed that in version 0.4.1 of Pytorch the nn.Upsample is being replace by F.interpolate

However due to that change, reusable blocks that contain a nn.Upsample step become difficult (or at least less elegant) to refactor:

         self.block = nn.Sequential(
                nn.Upsample(scale_factor=2, mode='bilinear', align_corners=False),
                ConvRelu(in_channels, middle_channels),
                ConvRelu(middle_channels, out_channels),

As a result I need to put to introduce a wrapper function or put an extra line of code in the forward method for every used block. It doesn’t seem to add to the maintainability of the model.

I was wondering is there a more elegant way to refactor the above that I missed?

Or perhaps in the future a nn.interpolate will be introduced? (similar to having both nn.ReLU and F.relu)