-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Bilinear upsampling fix #5511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bilinear upsampling fix #5511
Conversation
|
@pytorchbot test this please |
|
Hi @Dorimer, this is great! I know you have tested this fix visually, but I am wondering if there isn't a automatic test we can add to the test suite to prevent this from regressing if someone ever reimplements this kernel. Perhaps doing the allclose computation on the two differently sized inputs? |
|
@Dorimer If you don't have time working on adding a test, I am happy to write one. |
|
@ssnl Yes, I tried to understand the testing system a couple of times, but as you said I don't have much time right now, so my progress is very slow. I'll be glad if you can add a test, thank you in advance =) |
|
The fix is not ideal. You end up with I suggest doing what tf does, i.e. having an Let me what you think. @Dorimer @soumith @colesbury |
This is not an error, because it is a formal bilinear interpolation behaviour, which strictly follows the definition in Wikipedia. It is also identical with caffe's upsampling as shown here: https://gist.github.com/Dorimer/93470646cdac125b36ab54e742796571 |
|
@Dorimer I see. I think what you said makes sense. I'll think more about it tomorrow. Thanks! |
|
@Dorimer I agree that the |
|
I believe this can be closed. |
Hello,
While working on transferring neural network architecture from PyTorch to Caffe I noticed a serious difference between PyTorch bilinear upsampling layer and a Caffe's deconvolution with bilinear kernel.
After some research, it turned out that PyTorch bilinear upsampling code clearly has one problem: Result depends on spatial size, which means that, for example, two similar parts of two images won't be the same after upsampling if these images have different sizes.
This bug is caused by pixel coordinate computation trick, which is pretty, but inaccurate.
Visual example of the bug and the fix can be viewed here: https://gist.github.com/Dorimer/e2389bfc4dd86c7ebbea3a1f45fc4327