提交 0064f6d9 编写于 作者: F fengjiayi

refine test

上级 1f5f79cb
...@@ -34,6 +34,9 @@ fluid.backward.append_backward( ...@@ -34,6 +34,9 @@ fluid.backward.append_backward(
hidden1_grad = prog.block(0).var(hidden1.name + "@GRAD") hidden1_grad = prog.block(0).var(hidden1.name + "@GRAD")
hidden1_grad_clip = prog_clip.block(0).var(hidden1.name + "@GRAD") hidden1_grad_clip = prog_clip.block(0).var(hidden1.name + "@GRAD")
hidden2_grad = prog.block(0).var(hidden2.name + "@GRAD")
hidden2_grad_clip = prog_clip.block(0).var(hidden2.name + "@GRAD")
train_reader = paddle.batch( train_reader = paddle.batch(
paddle.reader.shuffle( paddle.reader.shuffle(
paddle.dataset.mnist.train(), buf_size=8192), paddle.dataset.mnist.train(), buf_size=8192),
...@@ -49,11 +52,16 @@ for data in train_reader(): ...@@ -49,11 +52,16 @@ for data in train_reader():
count += 1 count += 1
if count > 5: if count > 5:
break break
out = exe.run(prog, feed=feeder.feed(data), fetch_list=[hidden1_grad]) out1, out2 = exe.run(prog,
out_clip = exe.run(prog_clip, feed=feeder.feed(data),
feed=feeder.feed(data), fetch_list=[hidden1_grad, hidden2_grad])
fetch_list=[hidden1_grad_clip]) out1_clip, out2_clip = exe.run(
if not (out[0].clip(min=CLIP_MIN, max=CLIP_MAX) == out_clip[0]).all(): prog_clip,
feed=feeder.feed(data),
fetch_list=[hidden1_grad_clip, hidden2_grad_clip])
if not ((out1.clip(
min=CLIP_MIN, max=CLIP_MAX) == out1_clip).all() and
(out2 == out2_clip).all()):
exit(1) exit(1)
exit(0) exit(0)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册