Optimization, Pytorch, Machine Learning, Deep Learning, Tensorboard.
weight[target] nll = nll / weight[target].sum() sum_nll = nll.sum() return sum_nll # custom loss definition class CrossEntropyLoss(nn.Module): def forward(self, input, target): pred = log_softmax(input) loss = weighted_nll(pred, target, torch.Tensor([0.1] * num_classes).cuda()) return loss Last, we