torch_frame.nn.encoder.LinearPeriodicEncoder

class LinearPeriodicEncoder(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, n_bins: int | None = 16)[source]

Bases: StypeEncoder

A periodic encoder that utilizes sinusoidal functions to transform the input tensor into a 3-dimensional tensor. The encoding is defined using trainable parameters and includes the application of sine and cosine functions. The original encoding is described in “On Embeddings for Numerical Features in Tabular Deep Learning”.

Parameters:

n_bins (int) – Number of bins for periodic encoding.

reset_parameters() None[source]

Initialize the parameters of post_module.

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].