MSE ignore_index

Hi,

I’m working on rating prediction, more especially on sub-rating. People tend to not rate every proposed aspects. In order to alleviate the training, I would like to know if there exists a way to mimic efficiently the parameter ignore_index or CrossEntropyLoss or NLLLoss but using instead MSELoss.

Thanks for your answer

I know it is late, but I am also looking for the same answer. Here is what I got, hope it helps others who got the same question in the future.

    def mse_loss(self, input, target, ignored_index, reduction):
        mask = target == ignored_index
        out = (input[~mask]-target[~mask])**2
        if reduction == "mean":
            return out.mean()
        elif reduction == "None":
            return out
3 Likes