I’m trying to implement a masked loss function which only works on a certain region of the output. Over the training phase, the regions not considered in the loss are getting blown/vanish.
    def masked_l1_loss(self, x, trgt):
        mask = (trgt > -1).detach()
        diff = trgt - x
        diff = diff[mask]
        return diff.abs().mean()