Performance, Pytorch, Deep Learning, Artificial Intelligence, Tensorboard.
torch.profiler.record_function('count_nonzero'): num_unique = torch.count_nonzero(deriv)+1 # calculate the cross-entropy loss loss = self.cross_entropy(pred, target) # zero the loss in the case that the number of unique elements # is below the threshold with torch.profiler.record_function('where'):