Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change duration compute methods #49

Merged
merged 8 commits into from
Jan 19, 2018
Merged
12 changes: 8 additions & 4 deletions fluid/resnet50.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,16 @@ def run_benchmark(model, args):

iter = 0
im_num = 0
start_time = time.time()
for pass_id in range(args.pass_num):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

accuracy.reset(exe)
if iter == args.iterations:
break
iter = 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this modification right? What's the use of args.iterations ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it shoud be:
accuracy.reset(exe)
iter = 0
the args.iterations is used to limit the iterations in each pass, so it used in:
for batch_id, data in enumerate(train_reader()):

for batch_id, data in enumerate(train_reader()):
if iter == args.skip_batch_num:
if iter < args.skip_batch_num:
iter += 1
continue
if pass_id == 0:
start_time = time.time()
Copy link
Contributor

@ranqiu92 ranqiu92 Jan 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For all batches in pass 0, this line will be executed. Is this what you want?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modified

if iter == args.iterations:
break
Expand All @@ -195,9 +199,9 @@ def run_benchmark(model, args):
im_num += label.shape[0]

duration = time.time() - start_time
im_num = im_num - args.skip_batch_num * args.batch_size
#im_num = im_num - args.skip_batch_num * args.batch_size
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please delete the codes commented

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

examples_per_sec = im_num / duration
sec_per_batch = duration / (iter - args.skip_batch_num)
sec_per_batch = duration / (iter - args.skip_batch_num) / args.pass_num

print('\nTotal examples: %d, total time: %.5f' % (im_num, duration))
print('%.5f examples/sec, %.5f sec/batch \n' %
Expand Down