Hi. I am trying to build a standalone evaluation script using Pytorch Ignite. Yet, I am having trouble getting the desired output.
From the following code:
evaluator = create_evaluator(cfg, model, tokenizer, selected_metrics, logger)

    @evaluator.on(Events.ITERATION_COMPLETED(every=1) | Events.COMPLETED)
    def log_info():
        metrics_output = "\n".join(
            [f"\t{k}: {v}" for k, v in evaluator.state.metrics.items()]
        )

        logger.info(
            f"\nEvaluation time (seconds): {evaluator.state.times['COMPLETED']:.2f}\nValidation metrics:\n {metrics_output}"
        )

    try:
        state = evaluator.run(val_dataloader,)
    except Exception as e:
        logger.exception("")
        raise e

I get the following truncated output:

2022-01-06 16:32:30,537 Test INFO:
Evaluation time (seconds): 0.00
Validation metrics:
…
2022-01-06 16:32:32,628 Test INFO:
Evaluation time (seconds): 0.00
Validation metrics:
2022-01-06 16:32:32,628 Test INFO:
Evaluation time (seconds): 30.94
Validation metrics:
meteor: 0.2809806329259838
ter: 491.0379854211612

As you can see, only when the engine’s run is complete the output is correctly printed. Until then, every thing is zero. How can I properly get the evaluator’s state? Thank you.