Optimization, Pytorch, Machine Learning, Deep Learning, Tensorboard.
below contains our updated loss definition, which now uses torch.nn.NLLLoss. class CrossEntropyLoss(nn.Module): def __init__(self): super().__init__() self.weight = torch.Tensor([0.1]*num_classes).cuda() def forward(self, input, target): pred = log_softmax(input) nll = torch.nn.NLLLoss(self.weight)