ignite.engine.supervised_evaluation_step(model, device=None, non_blocking=False, prepare_batch=<function _prepare_batch>, model_transform=<function <lambda>>, output_transform=<function <lambda>>, model_fn=<function <lambda>>)[source]#

Factory function for supervised evaluation.

  • model (Module) – the model to train.

  • device (Optional[Union[str, device]]) – device type specification (default: None). Applies to batches after starting the engine. Model will not be moved.

  • non_blocking (bool) – if True and this copy is between CPU and GPU, the copy may occur asynchronously with respect to the host. For other cases, this argument has no effect.

  • prepare_batch (Callable) – function that receives batch, device, non_blocking and outputs tuple of tensors (batch_x, batch_y).

  • model_transform (Callable[[Any], Any]) – function that receives the output from the model and convert it into the predictions: y_pred = model_transform(model(x)).

  • output_transform (Callable[[Any, Any, Any], Any]) – function that receives ‘x’, ‘y’, ‘y_pred’ and returns value to be assigned to engine’s state.output after each iteration. Default is returning (y_pred, y,) which fits output expected by metrics. If you change it you should use output_transform in metrics.

  • model_fn (Callable[[Module, Any], Any]) – the model function that receives model and x, and returns y_pred.


Inference function.

Return type



engine.state.output for this engine is defined by output_transform parameter and is a tuple of (batch_pred, batch_y) by default.


The internal use of device has changed. device will now only be used to move the input data to the correct device. The model should be moved by the user before creating an optimizer.

New in version 0.4.5.

Changed in version 0.4.12: Added model_transform to transform model’s output

Changed in version 0.4.13: Added model_fn to customize model’s application on the sample