提交 a785a837 编写于 作者: H Helin Wang

update the example with the latest API

上级 3eef539a
......@@ -94,7 +94,7 @@ def train(use_cuda, is_sparse, save_path):
place = fluid.CUDAPlace(0) if use_cuda else fluid.CPUPlace()
def event_handler(event):
if isinstance(event, fluid.EndPass):
if isinstance(event, fluid.Event.END_EPOCH):
avg_cost = trainer.test(reader=paddle.dataset.imikolov.test(
word_dict, N))
......@@ -106,10 +106,9 @@ def train(use_cuda, is_sparse, save_path):
trainer = fluid.Trainer(
partial(inference_network, is_sparse),
optimizer=fluid.optimizer.SGD(learning_rate=0.001),
place=place,
event_handler=event_handler)
trainer.train(train_reader, 100)
fluid.optimizer.SGD(learning_rate=0.001),
place=place)
trainer.train(train_reader, 100, event_handler)
def infer(use_cuda, save_path):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册