Performance, Pytorch, Deep Learning, Artificial Intelligence, Tensorboard.
case, fixing this issue is rather simple as the PyTorch CrossEntropyLoss has a built-in option for setting an ignore_index. class MaskedLoss(nn.Module): def __init__(self, ignore_val=-1, num_classes=10): super().__init__() self.ignore_val = ignore_val self.num_classes = num_classes self.loss =