pytorch / maskedtensor

MaskedTensors for PyTorch
https://pytorch.org/maskedtensor
Other
38 stars 10 forks source link

Support mse_loss #60

Open johnnynunez opened 2 years ago

johnnynunez commented 2 years ago

🚀 The feature, motivation and pitch

Many developers, like myself, use masks in both the prediction output and ground truth to evaluate whether or not an image, for example, is valid for backpropagation.

Alternatives

In my case it is not the same to do x[mask] -> NaN error loss in model x * mask -> 0.0 good Masked tensor(x, mask) - - error F.mse_loss...

Additional context

image

cpuhrsch commented 2 years ago

Hello @johnnynunez - Thank you for opening the issue!

Next to mse_loss, do you have a list of models for which you'd like to see MaskedTensor support? Likely this won't stop at the loss, but then also apply to operators used during the backward pass.

johnnynunez commented 2 years ago

I can't tell you @cpuhrsch right now. Only that I have had most of the problems you report in the document. I think this repository is a very good idea. I also used masked_select from pytorch but it only works with 1D, my output, target and mask is [32,1,1,1,20,2].

cpuhrsch commented 2 years ago

@johnnynunez - Ok sounds good, so to make this issue more concrete, maybe we'll only focus it on mse_loss for now?

johnnynunez commented 2 years ago

@johnnynunez - Ok sounds good, so to make this issue more concrete, maybe we'll only focus it on mse_loss for now?

I think that's right!

cpuhrsch commented 2 years ago

@johnnynunez - Sounds good. I edited the title to reflect this.