Optimization, Pytorch, Machine Learning, Deep Learning, Tensorboard.
super().__init__() self.weight = torch.Tensor([0.1]*num_classes).cuda() def forward(self, input, target): with torch.profiler.record_function('log_softmax'): pred = log_softmax(input) with torch.profiler.record_function('weighted_nll'): loss = weighted_nll(pred, target, self.weight) return loss The