From a785a837b97c8790c34d16e140df1c4d92b7cf90 Mon Sep 17 00:00:00 2001 From: Helin Wang Date: Tue, 1 May 2018 16:50:38 -0700 Subject: [PATCH] update the example with the latest API --- .../tests/book/word2vec/no_test_word2vec_new_api.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/python/paddle/fluid/tests/book/word2vec/no_test_word2vec_new_api.py b/python/paddle/fluid/tests/book/word2vec/no_test_word2vec_new_api.py index 1e31824aa..272db7b57 100644 --- a/python/paddle/fluid/tests/book/word2vec/no_test_word2vec_new_api.py +++ b/python/paddle/fluid/tests/book/word2vec/no_test_word2vec_new_api.py @@ -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): -- GitLab