peal.global_utils.onehot¶
- peal.global_utils.onehot(label, n_classes)[source]¶
One-hot encode a batch of class indices.
- Parameters:
label (
torch.Tensor) – Class indices of shape(B,)(or anything reshapeable to(B, 1)).n_classes (
int) – Width of the encoding.
- Returns:
Float tensor of shape
(B, n_classes)on the device oflabel.- Return type: