nn.Upsample with align_corners=True

Does anyone know how ‘nn.Upsample’ works when its ‘align_corners’ parameter is set to True?

So, when you have a tensor as below

source : tensor([[[[ 2, -5, 10, 4 ]]]])

and apply upsample operation to it.

m = torch.nn.Upsample(scale_factor=2, mode=‘bilinear’, align_corners=True)
result = m(source)

Finally, get result as

tensor([[[[ 2.0, -1.0, -4.0, -0.7143, 5.7143, 9.1429, 6.5714, 4.0 ]]]])

So my question here is, how do I calculate these values from source-tensor?

1 Like