cursus.steps.hyperparams.hyperparameters_tsa

class TemporalSelfAttentionHyperparameters(*, full_field_list, cat_field_list, tab_field_list, id_name, label_name, multiclass_categories, categorical_features_to_encode=<factory>, model_class='temporal_self_attention', device=-1, header=0, lr=3e-05, batch_size=2, eval_batch_size_multiplier=2.0, max_epochs=3, metric_choices=['f1_score', 'auroc'], optimizer='SGD', class_weights=None, n_embedding, n_cat_features, n_num_features, seq_len, seq_cat_key='x_seq_cat', seq_num_key='x_seq_num', seq_time_key='time_seq', engineered_key='x_engineered', dim_embedding_table=128, dim_attn_feedforward=512, num_heads=8, n_layers_order=2, n_layers_feature=2, dropout=0.1, use_moe=False, num_experts=4, expert_capacity_factor=1.25, expert_dropout=0.1, use_time_seq=True, time_encoding_dim=32, return_seq=False, use_key_padding_mask=True, loss='CrossEntropyLoss', loss_alpha=0.25, loss_gamma=2.0, loss_gamma_min=1.0, loss_gamma_max=3.0, loss_cycle_length=1000, loss_reduction='mean', weight_decay=0.0, adam_epsilon=1e-08, warmup_steps=300, run_scheduler=True)[source]

Bases: ModelHyperparameters

Hyperparameters for Temporal Self-Attention (TSA) model training, extending the base ModelHyperparameters.

Fields are organized into three tiers: 1. Tier 1: Essential User Inputs - fields that users must explicitly provide 2. Tier 2: System Inputs with Defaults - fields with reasonable defaults that can be overridden 3. Tier 3: Derived Fields - fields calculated from other fields (private attributes with properties)

n_embedding: int
n_cat_features: int
n_num_features: int
seq_len: int
model_class: str
seq_cat_key: str
seq_num_key: str
seq_time_key: str
engineered_key: str
dim_embedding_table: int
dim_attn_feedforward: int
num_heads: int
n_layers_order: int
n_layers_feature: int
dropout: float
use_moe: bool
num_experts: int
expert_capacity_factor: float
expert_dropout: float
use_time_seq: bool
time_encoding_dim: int
return_seq: bool
use_key_padding_mask: bool
loss: str
loss_alpha: float
loss_gamma: float
loss_gamma_min: float
loss_gamma_max: float
loss_cycle_length: int
loss_reduction: str
weight_decay: float
adam_epsilon: float
warmup_steps: int
run_scheduler: bool
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'protected_namespaces': (), 'validate_assignment': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

property model_config_dict: Dict[str, Any]

Get complete model configuration dictionary derived from hyperparameters.

validate_tsa_hyperparameters()[source]

Validate TSA-specific hyperparameters and initialize derived fields.

get_public_init_fields()[source]

Override get_public_init_fields to include TSA-specific derived fields. Gets a dictionary of public fields suitable for initializing a child config.

get_trainer_config()[source]

Get trainer configuration dictionary for PyTorch Lightning. This combines various trainer-related settings.

Returns:

Configuration dictionary for trainer

Return type:

Dict[str, Any]

model_post_init(context, /)

This function is meant to behave like a BaseModel method to initialize private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self (BaseModel) – The BaseModel instance.

  • context (Any) – The context.

full_field_list: List[str]
cat_field_list: List[str]
tab_field_list: List[str]
id_name: str
label_name: str
multiclass_categories: List[int | str]
categorical_features_to_encode: List[str]
device: int
header: int
lr: float
batch_size: int
eval_batch_size_multiplier: float
max_epochs: int
metric_choices: List[str]
optimizer: str
class_weights: List[float] | None