提交 bc3167d3 编写于 作者: W wanghaoshuang

Fix random seed.

上级 9f4a4810
...@@ -17,6 +17,7 @@ from paddle.fluid.initializer import init_on_cpu ...@@ -17,6 +17,7 @@ from paddle.fluid.initializer import init_on_cpu
if 'ce_mode' in os.environ: if 'ce_mode' in os.environ:
np.random.seed(10) np.random.seed(10)
fluid.default_startup_program().random_seed = 90
parser = argparse.ArgumentParser(description=__doc__) parser = argparse.ArgumentParser(description=__doc__)
add_arg = functools.partial(add_arguments, argparser=parser) add_arg = functools.partial(add_arguments, argparser=parser)
...@@ -91,9 +92,6 @@ def train(args): ...@@ -91,9 +92,6 @@ def train(args):
place = fluid.CUDAPlace(0) place = fluid.CUDAPlace(0)
exe = fluid.Executor(place) exe = fluid.Executor(place)
if 'ce_mode' in os.environ:
fluid.default_startup_program().random_seed = 90
exe.run(fluid.default_startup_program()) exe.run(fluid.default_startup_program())
if args.init_model is not None: if args.init_model is not None:
...@@ -126,8 +124,9 @@ def train(args): ...@@ -126,8 +124,9 @@ def train(args):
sub124_loss += results[3] sub124_loss += results[3]
# training log # training log
if iter_id % LOG_PERIOD == 0: if iter_id % LOG_PERIOD == 0:
print("Iter[%d]; train loss: %.3f; sub4_loss: %.3f; sub24_loss: %.3f; sub124_loss: %.3f" % ( print(
iter_id, t_loss / LOG_PERIOD, sub4_loss / LOG_PERIOD, "Iter[%d]; train loss: %.3f; sub4_loss: %.3f; sub24_loss: %.3f; sub124_loss: %.3f"
% (iter_id, t_loss / LOG_PERIOD, sub4_loss / LOG_PERIOD,
sub24_loss / LOG_PERIOD, sub124_loss / LOG_PERIOD)) sub24_loss / LOG_PERIOD, sub124_loss / LOG_PERIOD))
print("kpis train_cost %f" % (t_loss / LOG_PERIOD)) print("kpis train_cost %f" % (t_loss / LOG_PERIOD))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册