Hello all
I am a beginner in deep learning and pytorch and train my model like code below. I want to ask is it possible to save my elapsed time per epoch in a file . I want to do it because i want to see the max,min,and average elapsed time.
epochs = 5
train_losses=[]
for epochs in range(epochs):
t0 = time.time()
model.train()
for batch_idx, (x,y) in enumerate(loader):
x,y = x.to(device), y.to(device)
optimizer.zero_grad()
outputs = model(x)
loss = loss_fn(outputs,y)
loss.backward()
optimizer.step()
StopatLossValue()
# program timing
torch.cuda.synchronize()
t1 = time.time()
eta = t1-t0
if batch_idx % 100 == 0:
print('Train Epoch: {} \t Loss: {:.6f} \t Elapsed time :{:.2f} ms'.format(epochs, loss.item(), ((eta)*1000)))