SymmetricLCWATrainingLoop
- class SymmetricLCWATrainingLoop(model: Model, triples_factory: CoreTriplesFactory, optimizer: str | Optimizer | type[Optimizer] | None = None, optimizer_kwargs: Mapping[str, Any] | None = None, lr_scheduler: str | LRScheduler | type[LRScheduler] | None = None, lr_scheduler_kwargs: Mapping[str, Any] | None = None, automatic_memory_optimization: bool = True, mode: Literal['training', 'validation', 'testing'] | None = None, result_tracker: str | ResultTracker | type[ResultTracker] | None = None, result_tracker_kwargs: Mapping[str, Any] | None = None)[source]
Bases:
TrainingLoop
[tuple
[Tensor
],tuple
[Tensor
]]A “symmetric” LCWA scoring heads and tails at once.
This objective was introduced by [lacroix2018] as
\[l_{i,j,k}(X) = - X_{i,j,k} + \log \left( \sum_{k'} \exp(X_{i,j,k′}) \right) - X_{k,j+P,i} + \log \left( \sum_{i'} \exp (X_{k, j+P, i'}) \right)\]which can be seen as a “symmetric LCWA”, where for one batch of triples, we score both, heads and tails, given the remainder of the triple.
Note
at the same time, there is a also a difference to the
LCWATrainingLoop
: we do not group by e.g., head+relation pairs. Thus, the name might be suboptimal and change in the future.Initialize the training loop.
- Parameters:
model (Model) – The model to train
triples_factory (CoreTriplesFactory) – The training triples factory
optimizer (Optimizer) – The optimizer to use while training the model
optimizer_kwargs (Mapping[str, Any] | None) – additional keyword-based parameters to instantiate the optimizer (if necessary). params will be added automatically based on the model.
lr_scheduler (LRScheduler | None) – The learning rate scheduler you want to use while training the model
lr_scheduler_kwargs (Mapping[str, Any] | None) – additional keyword-based parameters to instantiate the LR scheduler (if necessary). optimizer will be added automatically.
automatic_memory_optimization (bool) – bool Whether to automatically optimize the sub-batch size during training and batch size during evaluation with regards to the hardware at hand.
mode (Literal['training', 'validation', 'testing'] | None) – The inductive training mode. None if transductive.
result_tracker (str | ResultTracker | type[ResultTracker] | None) – the result tracker
result_tracker_kwargs (Mapping[str, Any] | None) – additional keyword-based parameters to instantiate the result tracker