torch_frame.nn.encoder.FeatureEncoder

class FeatureEncoder(*args, **kwargs)[source]

Bases: Module, ABC

Base class for feature encoder that transforms input torch_frame.TensorFrame into (x, col_names), where x is the colum-wise PyTorch tensor of shape [batch_size, num_cols, channels] and col_names is the names of the columns. This class contains learnable parameters and missing value handling.

abstract forward(tf: TensorFrame) tuple[torch.Tensor, list[str]][source]

Encode TensorFrame object into a tuple (x, col_names).

Parameters:

tf (torch_frame.TensorFrame) – Input TensorFrame object.

Returns:

A tuple of an output column-wise

torch.Tensor of shape [batch_size, num_cols, hidden_channels] and a list of column names of x. The length needs to be num_cols.

Return type:

(torch.Tensor, List[str])

reset_parameters() None[source]

Resets all learnable parameters of the module.