Skip to content

Commit

Permalink
Fix total time
Browse files Browse the repository at this point in the history
  • Loading branch information
kuangliu committed Jan 21, 2017
1 parent 8c948e2 commit c09e38b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 0 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

'''Train CIFAR10 with PyTorch.'''
from __future__ import print_function

Expand Down Expand Up @@ -31,7 +30,6 @@

classes = ('plane', 'car', 'bird', 'cat', 'deer', 'dog', 'frog', 'horse', 'ship', 'truck')


# Model.
print('==> Building model..')
class Net(nn.Module):
Expand Down
8 changes: 6 additions & 2 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@ def get_mean_and_std(dataset):
last_time = time.time()
begin_time = last_time
def progress_bar(current, total, msg=None):
global last_time
sys.stdout.write(' [')
global last_time, begin_time
if current == 0:
begin_time = time.time() # Reset for new bar.

cur_len = int(TOTAL_BAR_LENGTH*current/total)
rest_len = int(TOTAL_BAR_LENGTH - cur_len) - 1

sys.stdout.write(' [')
for i in range(cur_len):
sys.stdout.write('=')
sys.stdout.write('>')
Expand All @@ -56,6 +59,7 @@ def progress_bar(current, total, msg=None):
cur_time = time.time()
step_time = cur_time - last_time
last_time = cur_time

tot_time = cur_time - begin_time
L.append(' Step: %s' % format_time(step_time))
L.append(' | Tot: %s' % format_time(tot_time))
Expand Down

0 comments on commit c09e38b

Please sign in to comment.