torch_frame.nn.encoder.ExcelFormerEncoder

class ExcelFormerEncoder(out_channels: Optional[int] = None, stats_list: Optional[list[dict[torch_frame.data.stats.StatType, Any]]] = None, stype: Optional[stype] = None, post_module: Optional[Module] = None, na_strategy: Optional[NAStrategy] = None)[source]

Bases: StypeEncoder

An attention based encoder that transforms input numerical features to a 3-dimensional tensor.

Before being fed to the embedding layer, numerical features are normalized and categorical features are transformed into numerical features by the CatBoost Encoder implemented with the Sklearn Python package. The features are then ranked based on mutual information. The original encoding is described in “ExcelFormer: A Neural Network Surpassing GBDTs on Tabular Data” paper.

Parameters:
  • out_channels (int) – The output channel dimensionality.

  • stats_list (list[dict[StatType, Any]]) – The list of stats for each column within the same stype.

encode_forward(feat: Tensor, col_names: Optional[list[str]] = None) Tensor[source]

The main forward function. Maps input feat from TensorFrame (shape [batch_size, num_cols]) into output x of shape [batch_size, num_cols, out_channels].

reset_parameters() None[source]

Initialize the parameters of post_module.