Search code examples
pythonpytorchinterpolationimage-resizing

torch.nn.functional.interpolate: difference between "linear" and "bilinear"?


In torch.nn.functional.interpolate what's the difference between the modes linear and bilinear?

To me, these are usually synonyms with regards to image resizing...


Solution

  • Pytorch is explicitly differentiating between 1d interpolation (linear) and 2d interpolation (bilinear).

    They differ in the the dimensionality of the input argument they are allowed to work on ( see here ). Specifically, linear works on 3D inputs and bilinear works on 4D inputs because the first two dimensions (mini-batch x channels) are understood not to be interpolated.