Skip to content

Conversation

@zou3519
Copy link
Contributor

@zou3519 zou3519 commented Jun 21, 2018

THNN was accumulating the result of reduction loss functions
into real instead of accreal. This was causing precision issues with
MSELoss.

I added precision tests for some of the losses (KLDivLoss, BCELoss,
L1Loss, SmoothL1Loss, MSELoss). The other ones are a bit harder
to test.

This patch only fixes MSELoss. Some of the other losses exhibit bad precision as well (because they accumulate into real instead of accreal) and require more investigation. I will open an issue for those.

Fixes #8710

THNN was accumulating the result of reduction loss functions
into real instead of accreal. This was causing precision issues with
MSELoss.

I added precision tests for some of the losses (KLDivLoss, BCELoss,
L1Loss, SmoothL1Loss, MSELoss). The other ones are a bit harder
to test.
@ssnl
Copy link
Collaborator

ssnl commented Jun 21, 2018

Nice! The new tests are written with good *tol so they fail before this patch, right?

@zou3519
Copy link
Contributor Author

zou3519 commented Jun 21, 2018

Don't merge this yet, I think some of the tests are going to fail. @ssnl yes I checked that all of precision tests that I added fail before this patch.

@li-roy
Copy link
Contributor

li-roy commented Jun 21, 2018

Does it make sense to include these tests if the only reason is so that they fail before this patch and pass after it? I feel that they might not be that helpful in the future.

@ssnl
Copy link
Collaborator

ssnl commented Jun 21, 2018

@li-roy They can prevent regression. Haven't we always been adding tests along with fixes?

@ezyang
Copy link
Contributor

ezyang commented Jul 8, 2018

@zou3519 Don't forget about this patch!

@zou3519
Copy link
Contributor Author

zou3519 commented Jul 9, 2018

I'll rebase and submit this with only the MSELoss changes. The other losses have similar precision issues but those require more looking into and aren't immediately solved by accumulating into accreal instead of real.

@zou3519
Copy link
Contributor Author

zou3519 commented Jul 9, 2018

Closing in favor of #9287

@zou3519 zou3519 closed this Jul 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect calculation for torch.nn.MSELoss

5 participants