PyTorch One-Hot Labels | Jacob C. Kimmel
jck.bio/pytorch_onehot15.11.2017 · PyTorch One-Hot Labels Wednesday. November 15, 2017 - 2 mins . software deep learning pytorch. Some interesting loss functions in deep learning require “one-hot” labels. A “one-hot” label is simply a binary array of dimensions dim0...dimN, C, where C is the number of classes in your label.
torch.nn.functional.one_hot — PyTorch 1.10.1 documentation
pytorch.org › torchtorch.nn.functional.one_hot¶ torch.nn.functional. one_hot (tensor, num_classes =-1) → LongTensor ¶ Takes LongTensor with index values of shape (*) and returns a tensor of shape (*, num_classes) that have zeros everywhere except where the index of last dimension matches the corresponding value of the input tensor, in which case it will be 1.