I need to save a file with the average elapsed time per epoch and I found this function on the documentation:
t = Timer(average=True) for _ in range(10): work() idle() t.step()
def save_time(engine): torch.save(t.value(),'time.pt´) trainer.add_event_handler(Events.EPOCH_STARTED(every=3), save_time)
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.