this works but It shows the elapsed time in 3 epochs and I suppose the file overwrites every 3 epochs but what I want is to calculate the average time just once for the first epoch and stop the timer. I don’t want to divide timer value between 3, also I don’t want to generate one file per epoch. One option is to run my code with just one epoch but I am running several models and I would like to generate this just once every time I am going to train.
How can I achieve this?
pd: the documentation show an example doing it by iteration, but I am unable to translate this example to epoch. I believe the documentation should extend to epoch example as well.
An other option is to use directly Timer (without step to do not average)
timer = Timer()
@trainer.on(Events.STARTED)
def time_start():
# reset the timer at the beginning
timer.reset()
@trainer.on(Events.EPOCH_STARTED(every=3))
def time_start():
# use value() to get the time
print("timer of 3 epochs :", timer.value())
# reset the timer from now for 3 next epochs
timer.reset()
Last point I would like to mention, we recently added epoch timers in trainer.state.timers. That is another option which should help you to mesure epoch times
@trainer.on(Events.EPOCH_COMPLETED)
def print_timers():
# trainer.state.timers is a dict
print("timers=", trainer.state.timers)
If you need more support, don’t hesitate to ask, it would be a pleasure to help