torch_frame.nn.encoder.LinearModelEncoder
- class LinearModelEncoder(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, col_to_model_cfg: Optional[dict[str, torch_frame.config.model.ModelConfig]] = None)[source]
Bases:
StypeEncoderLinear function based encoder with a specified model outputs embedding features. It applies a linear layer
torch.nn.Linear(in_channels, out_channels)on each embedding feature (in_channelsis the dimensionality of the embedding) and concatenates the output embeddings. Themodelwill also be trained together with the linear layer. Note that the implementation does this for all columns in a batched manner.- Parameters:
col_to_model_cfg (dict) – A dictionary mapping column names to
ModelConfig, which specifies a model to map a single-columnTensorDataobject of shape[batch_size, 1, *]into row embeddings of shape[batch_size, 1, model_out_channels].
- encode_forward(feat: torch.Tensor | torch_frame.data.multi_nested_tensor.MultiNestedTensor | torch_frame.data.multi_embedding_tensor.MultiEmbeddingTensor | dict[str, torch_frame.data.multi_nested_tensor.MultiNestedTensor], col_names: Optional[list[str]] = None) Tensor[source]
The main forward function. Maps input
featfrom TensorFrame (shape [batch_size, num_cols]) into outputxof shape[batch_size, num_cols, out_channels].