Skip to content

Commit

Permalink
put the test at end of mnist example to avoid async update problem
Browse files Browse the repository at this point in the history
We should find a better way to do periodic test.
  • Loading branch information
bichengying committed Jun 3, 2020
1 parent 7e2a134 commit 167ca15
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions examples/pytorch_mnist.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def metric_average(val, name):
return avg_tensor.item()


def test():
def test(record):
model.eval()
test_loss = 0.0
test_accuracy = 0.0
Expand Down Expand Up @@ -276,12 +276,10 @@ def test():
test_loss, 100.0 * test_accuracy
)
)
return test_loss, 100.0 * test_accuracy
record.append((test_loss, 100.0 * test_accuracy))


record = []
test_record = []
for epoch in range(1, args.epochs + 1):
train(epoch)
record.append(test())

print(f"[{bf.rank()}]: ", record)
test(test_record)
print(f"[{bf.rank()}]: ", test_record)

0 comments on commit 167ca15

Please sign in to comment.