EmbeddingOneHot

The EmbeddingOneHot is an instance of the pytorch nn.Module class. This part of the neural network takes categorical samples and produces a one-hot encoded version of the input. This module is used in the from the Encoder.

class context_builder.embedding.EmbeddingOneHot(*args: Any, **kwargs: Any)[source]

Embedder using simple one hot encoding.

EmbeddingOneHot.__init__(input_size)[source]

Embedder using simple one hot encoding.

Parameters:

input_size (int) – Maximum number of inputs to one_hot encode

Forward

The forward() function takes the input values and produces the one-hot encoded equivalent. This method is also called from the __call__ method, i.e. when the object is called directly.

EmbeddingOneHot.forward(X)[source]

Create one-hot encoding of input

Parameters:

X (torch.Tensor of shape=(n_samples,)) – Input to encode.

Returns:

result – One-hot encoded version of input

Return type:

torch.Tensor of shape=(n_samples, input_size)