diff --git a/PaddleRec/ctr/dcn/infer.py b/PaddleRec/ctr/dcn/infer.py index 260bbe908ced74b7084a2be2390dd00f0812aaf1..83e49e0b20ee8422ec8a88da3ea3443c6bbfad15 100644 --- a/PaddleRec/ctr/dcn/infer.py +++ b/PaddleRec/ctr/dcn/infer.py @@ -45,7 +45,7 @@ def infer(): startup_program = fluid.framework.Program() test_program = fluid.framework.Program() cur_model_path = os.path.join(args.model_output_dir, - 'epoch_' + args.test_epoch) + 'epoch_' + args.test_epoch, "checkpoint") with fluid.scope_guard(inference_scope): with fluid.framework.program_guard(test_program, startup_program): @@ -62,10 +62,9 @@ def infer(): exe = fluid.Executor(place) feeder = fluid.DataFeeder( feed_list=dcn_model.data_list, place=place) - fluid.io.load_persistables( - executor=exe, - dirname=cur_model_path, - main_program=fluid.default_main_program()) + + exe.run(startup_program) + fluid.io.load(fluid.default_main_program(), cur_model_path) for var in dcn_model.auc_states: # reset auc states set_zero(var.name, scope=inference_scope, place=place) diff --git a/PaddleRec/ctr/dcn/local_train.py b/PaddleRec/ctr/dcn/local_train.py index d01d702f6b5cb985cbb168db006096d70bd68d4a..fd807e452048e760784198766a6cc283165c5e94 100644 --- a/PaddleRec/ctr/dcn/local_train.py +++ b/PaddleRec/ctr/dcn/local_train.py @@ -80,13 +80,10 @@ def train(args): debug=False, print_period=args.print_steps) model_dir = os.path.join(args.model_output_dir, - 'epoch_' + str(epoch_id + 1)) + 'epoch_' + str(epoch_id + 1), "checkpoint") sys.stderr.write('epoch%d is finished and takes %f s\n' % ( (epoch_id + 1), time.time() - start)) - fluid.io.save_persistables( - executor=exe, - dirname=model_dir, - main_program=fluid.default_main_program()) + fluid.save(fluid.default_main_program(), model_dir) if __name__ == '__main__': diff --git a/PaddleRec/ctr/xdeepfm/infer.py b/PaddleRec/ctr/xdeepfm/infer.py index 489d6337fe6a5abfc28a05707c74a56a2f9d513c..1c6277ad15f025bd3e14db473e7925e5200cb343 100644 --- a/PaddleRec/ctr/xdeepfm/infer.py +++ b/PaddleRec/ctr/xdeepfm/infer.py @@ -36,7 +36,7 @@ def infer(): startup_program = fluid.framework.Program() test_program = fluid.framework.Program() cur_model_path = os.path.join(args.model_output_dir, - 'epoch_' + args.test_epoch) + 'epoch_' + args.test_epoch, "checkpoint") with fluid.scope_guard(inference_scope): with fluid.framework.program_guard(test_program, startup_program): @@ -48,10 +48,9 @@ def infer(): exe = fluid.Executor(place) feeder = fluid.DataFeeder(feed_list=data_list, place=place) - fluid.io.load_persistables( - executor=exe, - dirname=cur_model_path, - main_program=fluid.default_main_program()) + + exe.run(startup_program) + fluid.io.load(fluid.default_main_program(), cur_model_path) for var in auc_states: # reset auc states set_zero(var.name, scope=inference_scope, place=place) diff --git a/PaddleRec/ctr/xdeepfm/local_train.py b/PaddleRec/ctr/xdeepfm/local_train.py index c5fc8a2eef2a05b0651e4b24c951cde50ebad976..2bb7e1deb90509bfea9fcd1e6ecde3038220fe5d 100644 --- a/PaddleRec/ctr/xdeepfm/local_train.py +++ b/PaddleRec/ctr/xdeepfm/local_train.py @@ -55,13 +55,10 @@ def train(): debug=False, print_period=args.print_steps) model_dir = os.path.join(args.model_output_dir, - 'epoch_' + str(epoch_id + 1)) + 'epoch_' + str(epoch_id + 1), "checkpoint") sys.stderr.write('epoch%d is finished and takes %f s\n' % ( (epoch_id + 1), time.time() - start)) - fluid.io.save_persistables( - executor=exe, - dirname=model_dir, - main_program=fluid.default_main_program()) + fluid.io.save_persistables(fluid.default_main_program(), model_dir) if __name__ == '__main__':