// Training loop - using batches of 32
loss_acc = 0.
step = 0
start = time.time()
for x, y in train_input_fn():
// Optimize the model
loss_value = optim.update(model, x, y)
loss_acc += loss_value
step += 1
print("training time {}".format(time.time() - start))
mean_loss = loss_acc / step
print("Training Loss {}".format(mean_loss))
After Change
num_epochs = args.epochs
timer = Timer()
for epoch in range(num_epochs):
// Training loop - using batches of 32
loss_acc = 0.
step = 0
timer.start()
for x, y in train_input_fn():
// Optimize the model
loss_value = optim.update(model, x, y)
loss_acc += loss_value
step += 1
print("training time {}".format(timer.elapsed()))
mean_loss = loss_acc / step
print("Training Loss {}".format(mean_loss))