Skip to content

Commit

Permalink
run train_step and eval step separately (#215)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgarithm authored and luomai committed Nov 16, 2019
1 parent 6f22b4f commit c234715
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions srcs/python/kungfu/tensorflow/v1/examples/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@ def sgd_example():
with tf.Session() as sess:
sess.run(init)
for step in range(5):
v, _ = sess.run([x, train_step])
# v, _ = sess.run([x, train_step]) # result is not deterministic!
sess.run(train_step)
v = sess.run(x)
print('step %d, result: %f' % (step, v))

u = (1 - 2 * lr)**(step + 1)
if abs(u - v) > 1e-6:
print('unexpected result: %f, want: %f' % (v, u))
msg = 'unexpected result: %f, want: %f' % (v, u)
print(msg)
raise RuntimeError(msg)


def main(args):
Expand Down

0 comments on commit c234715

Please sign in to comment.