TerminateOnNan#
- class ignite.handlers.terminate_on_nan.TerminateOnNan(output_transform=<function TerminateOnNan.<lambda>>)[source]#
TerminateOnNan handler can be used to stop the training if the process_function’s output contains a NaN or infinite number or torch.tensor. The output can be of type: number, tensor or collection of them. The training is stopped if there is at least a single number/tensor have NaN or Infinite value. For example, if the output is [1.23, torch.tensor(…), torch.tensor(float(‘nan’))] the handler will stop the training.
- Parameters
output_transform (Callable) – a callable that is used to transform the
Engine
’sprocess_function
’s output into a number or torch.tensor or collection of them. This can be useful if, for example, you have a multi-output model and you want to check one or multiple values of the output.
Examples
trainer.add_event_handler(Events.ITERATION_COMPLETED, TerminateOnNan())
Methods