To respond to : “Yes, internally, we check the signature of attached function and see if we can bind the function with and without the Engine.”
Strange… it doesn’t seem to work in this case:
def print_epoch(engine):
print("The training epoch is: " + str(engine.state.epoch))
trainer.add_event_handler(
Events.EPOCH_COMPLETED(every=1), print_epoch()
)
The error is : “TypeError: print_epoch() missing 1 required positional argument: ‘engine’”
I get the same error if I do:
trainer.add_event_handler(
Events.EPOCH_COMPLETED(every=1), print_epoch(), trainer
)