转onehot

one_hot = F.one_hot(label.long(), num_classes=n_classes)

转回来

label = torch.argmax(one_hot, -1)

相关文章: