I’m using 1.0.0.dev20190312. You could use the nightly build or if you prefer to stay in 1.0.1post2, you could use this code to create the one-hot encoded targets:
one_hot_labels = torch.zeros(labels.size(0), nb_classes, dtype=torch.long).scatter_(1, labels.unsqueeze(1), 1)