araffin / srl-zoo

State Representation Learning (SRL) zoo with PyTorch - Part of S-RL Toolbox
https://srl-zoo.readthedocs.io/en/latest/
MIT License
162 stars 18 forks source link

Weird behavior of mse_loss with pytorch 0.4.1 #22

Closed araffin closed 6 years ago

araffin commented 6 years ago

In reconstructionLoss() (losses/losses.py) this does yield the same output with pytorch 0.4.1 (pytorch 0.4 not affected):

F.mse_loss(input_image, target_image, reduction='elementwise_mean')
F.mse_loss(input_image, target_image, reduction='sum')

To reproduce the bug:

import torch as th
import torch.nn.functional as F

a = th.ones(10, 10)
a.requires_grad_(True)
b = a.clone() * 2
print(F.mse_loss(a, b, reduction='elementwise_mean'))
print(F.mse_loss(a, b, reduction='sum'))
araffin commented 6 years ago

Submitting issue to pytorch main repo

araffin commented 6 years ago

Fixed on pytorch master branch: https://github.com/pytorch/pytorch/issues/10009 TODO: update code when new release is out