Hi!
I am trying to compute softmax_cross_entropy_with_logits 27 in PyTorch. I couldn’t get the existing APIs working because of the smoothed labels. In my case where logits and labels have shape [2,3,4], I currently use following function -
def softmax_and_cross_entropy(logits, labels):
  return -(labels * nn.LogSoftmax(dim=2)(logits)).sum(dim=2)

I would like to know if there is a better way to go about it so that the function could be in a more pytorch style and backward could also get faster.