EvaluationTrainingCallback

class EvaluationTrainingCallback(*, evaluation_triples: Tensor, frequency: int = 1, evaluator: str | Evaluator | type[Evaluator] | None = None, evaluator_kwargs: Mapping[str, Any] | None = None, prefix: str | None = None, **kwargs)[source]

Bases: TrainingCallback

A callback for regular evaluation.

Example: evaluate training performance

from pykeen.datasets import get_dataset
from pykeen.pipeline import pipeline

dataset = get_dataset(dataset="nations")
result = pipeline(
    dataset=dataset,
    model="mure",
    training_loop_kwargs=dict(
        result_tracker="console",
    ),
    training_kwargs=dict(
        num_epochs=100,
        callbacks="evaluation",
        callback_kwargs=dict(
            evaluation_triples=dataset.training.mapped_triples,
            prefix="training",
        ),
    ),
)

Initialize the callback.

Parameters:
  • evaluation_triples (MappedTriples) – the triples on which to evaluate

  • frequency (int) – the evaluation frequency in epochs

  • evaluator (HintOrType[Evaluator]) – the evaluator to use for evaluation, cf. evaluator_resolver

  • evaluator_kwargs (OptionalKwargs) – additional keyword-based parameters for the evaluator

  • prefix (str | None) – the prefix to use for logging the metrics

  • kwargs – additional keyword-based parameters passed to evaluate

Methods Summary

post_epoch(epoch, epoch_loss, **kwargs)

Call after epoch.

Methods Documentation

post_epoch(epoch: int, epoch_loss: float, **kwargs: Any) None[source]

Call after epoch.

Parameters:
Return type:

None