rllm.nn.models.TableResNet

class rllm.nn.models.TableResNet(hidden_dim: int, out_dim: int, num_layers: int, metadata: Dict[ColType, List[Dict[str, Any]]], normalization: str | None = 'layer_norm', dropout: float = 0.2)[source]

Bases: Module

The ResNet-like TNN introduced in the “Revisiting Deep Learning Models for Tabular Data” paper.

Parameters:
  • hidden_dim (int) – The hidden dimension.

  • out_dim (int) – The output dimension.

  • num_layers (int) – The number of layers.

  • metadata (Dict[ColType, List[Dict[str, Any]]]) – The metadata of the table.

  • normalization (str | None) – The normalization method. (default: "layer_norm")

  • dropout (float) – The dropout rate. (default: 0.2)

Example

>>> import torch
>>> from rllm.nn.models import TableResNet
>>> from rllm.types import ColType
>>> metadata = {ColType.NUMERICAL: [{"name": "x"}]}
>>> model = TableResNet(hidden_dim=64, out_dim=1, num_layers=2, metadata=metadata)
forward(table: TableData) Tensor[source]

Encode a table into a fixed-size feature vector.

Parameters:

table (TableData) – Input table data.

Returns:

Output representations of shape [batch_size, out_dim].

Return type:

Tensor

reset_parameters()[source]

Resets all learnable parameters of the module.