Skip to content
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

MSE Loss is not capable of handling ignored targets #21

Open
SebieF opened this issue Jun 23, 2022 · 0 comments
Open

MSE Loss is not capable of handling ignored targets #21

SebieF opened this issue Jun 23, 2022 · 0 comments

Comments

@SebieF
Copy link
Collaborator

SebieF commented Jun 23, 2022

The PyTorch nn.MSELoss is not able to handle ignored indices (like the nn.CrossEntropyLoss).

A solution provided by @mheinzinger would be as follows:

You could easily implement this by yourself by passing "reduce=None" when initializing your loss function. As a result it will return a loss for each residue in your input instead of a single scalar. Then you can manually multiply the masked elements by 0 and average. When averaging, divide only by the number of non-masked residues.

This must be kept in mind for implementing residue(s)_to_value protocols in the future.

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

No branches or pull requests

1 participant