Hi,
First of all, upsample_* methods are deprecated in favor of interpolate.
But the difference is because of the fact that upsample_* uses interpolate function with arg align_corners=True while default value for interpolate method is align_corners=False. Actually, if you use upsample_* method, it gives you a deprecation warning that states the mentioned behavior.
Following code gives you the same output as old (deprecated) code:
nn.functional.interpolate(a, scale_factor=2, mode='bilinear', align_corners=True)

Official documentations also explain this behavior clearly:
https://pytorch.org/docs/stable/generated/torch.nn.UpsamplingBilinear2d.html 6
image698×115 5.36 KB
https://pytorch.org/docs/stable/nn.functional.html#torch.nn.functional.interpolate 5
image701×162 15.2 KB