I think I might find a small problem of this function. Please can you let me know if I am right on this.
When align_corners=False
, this line maps normalized coordinate in [-1,1] to [-0.5, size
- 0.5]. Then, it is possible to have coordinates larger than size-1
after this mapping. Let’s say we have a coordinate mapped to (x, y) with x > size-1
. Then the bilinear interpolation for (x, y) will use x0 = floor(x), x1 = x0+1, y0 = floor(y), y1 = y0 + 1, as shown here. Since x > size-1
, we actually have x0 = size-1
and x1=size
. As a result, although we have four points (x0, y0), (x1, y0), (x0, y1), (x1, y1) for interpolation, (x1, y0) and (x1, y1) will not be involved in calculation as indicated by codes here and here. Now, the result of bilinear interpolation becomes a weighted sum of features at (x0, y0) and (x0, y1), with their original bilinear interpolation weights. As we only have two points, the weights do not sum to 1. This contradicts a little bit to the idea of bilinear interpolation where the sum of weights for features at all coordinates is 1 (i.e. some kind of average despite of varying weights).
Is my understanding for the code correct? Could this be a problem for marginal cases? Thank you for your help!