Skip to content

sanity_checks

allennlp.training.callbacks.sanity_checks

[SOURCE]


SanityChecksCallback

@TrainerCallback.register("sanity_checks")
class SanityChecksCallback(TrainerCallback)

Performs model sanity checks.

Checks performed:

  • NormalizationBiasVerification for detecting invalid combinations of bias and normalization layers. See allennlp.sanity_checks.normalization_bias_verification for more details.

Note: Any new sanity checks should also be added to this callback.

on_start

class SanityChecksCallback(TrainerCallback):
 | ...
 | def on_start(
 |     self,
 |     trainer: "GradientDescentTrainer",
 |     is_primary: bool = True,
 |     **kwargs
 | ) -> None

on_batch

class SanityChecksCallback(TrainerCallback):
 | ...
 | def on_batch(
 |     self,
 |     trainer: "GradientDescentTrainer",
 |     batch_inputs: List[TensorDict],
 |     batch_outputs: List[Dict[str, Any]],
 |     batch_metrics: Dict[str, Any],
 |     epoch: int,
 |     batch_number: int,
 |     is_training: bool,
 |     is_primary: bool = True,
 |     batch_grad_norm: Optional[float] = None,
 |     **kwargs
 | ) -> None

SanityCheckError

class SanityCheckError(Exception):
 | def __init__(self, message) -> None

The error type raised when a sanity check fails.