提交 311c92a4 编写于 作者: W wanghaoshuang

Add syntax 'with average_model.apply(exe)'

上级 f9653a6a
......@@ -81,17 +81,16 @@ def train(args, data_reader=dummy_reader):
sys.stdout.flush()
batch_id += 1
if model_average != None:
model_average.apply(exe)
error_evaluator.reset(exe)
for data in test_reader():
exe.run(inference_program, feed=get_feeder_data(data, place))
_, test_seq_error = error_evaluator.eval(exe)
if model_average != None:
model_average.restore(exe)
with model_average.apply(exe):
error_evaluator.reset(exe)
for data in test_reader():
exe.run(inference_program, feed=get_feeder_data(data, place))
_, test_seq_error = error_evaluator.eval(exe)
if model_average != None:
model_average.restore(exe)
print "\nEnd pass[%d]; Test seq error: %s.\n" % (
pass_id, str(test_seq_error[0]))
print "\nEnd pass[%d]; Test seq error: %s.\n" % (
pass_id, str(test_seq_error[0]))
def main():
args = parser.parse_args()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册