-
Notifications
You must be signed in to change notification settings - Fork 83
Open
Description
I am trying to use standardized metric such as images/sec to arrive at relative training speeds for different frameworks(e.g. PyTorch and TF). Have you computed such a metric, if not, what do you think of this approach.
modified run.py to compute images_per_sec rate. lines modified highlighted with "[KAL]"
=========================================
`
def train(model, loader, epoch, optimizer, criterion, device, dtype, batch_size, log_interval, scheduler):
model.train()
correct1, correct5 = 0, 0
batch_time = AverageMeter()
images_per_sec = AverageMeter()
for batch_idx, (data, target) in enumerate(tqdm(loader)):
if isinstance(scheduler, CyclicLR):
scheduler.batch_step()
data, target = data.to(device=device, dtype=dtype), target.to(device=device)
# [KAL] Take timestamp
end = time.time()
optimizer.zero_grad()
output = model(data)
loss = criterion(output, target)
loss.backward()
optimizer.step()
corr = correct(output, target, topk=(1, 5))
correct1 += corr[0]
correct5 += corr[1]
# [KAL] compute processing time for batch
batch_time.update(time.time() - end)
# [KAL] Based on batch size, calculate the images/sec rate
images_per_sec.update(batch_size / (time.time() - end)) `
Metadata
Metadata
Assignees
Labels
No labels