Created
August 13, 2019 19:32
-
-
Save Hanrui-Wang/5fa21b829c622e06d760dfc2012e9d13 to your computer and use it in GitHub Desktop.
convert a digits to one hot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print(labels.detach().numpy()) | |
labels.unsqueeze_(-1) | |
print(labels.detach().numpy()) | |
labels_onehot = torch.FloatTensor(batch_size, 10) | |
labels_onehot.zero_() | |
labels_onehot.scatter_(1, labels, 1) | |
print(labels_onehot.detach().numpy()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment