nip.utils.torch.OneHot

nip.utils.torch.OneHot#

class nip.utils.torch.OneHot(num_classes: int = -1)[source]#

One-hot encode a tensor.

Parameters:

num_classes (int, default=-1) – The number of classes to one-hot encode.

Methods Summary

__init__([num_classes])

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x)

One-hot encode the input tensor.

Attributes

T_destination

call_super_init

dump_patches

training

Methods

__init__(num_classes: int = -1)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x: Tensor) Tensor[source]#

One-hot encode the input tensor.

Parameters:

x (Tensor) – The input tensor.

Returns:

x_one_hot (Tensor) – The one-hot encoded tensor.