Skip to content

Use for_test=True in the Fluid Trainer to clone the test program #11323

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions python/paddle/fluid/inferencer.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ def __init__(self, infer_func, param_path, place=None, parallel=False):
else:
self.exe = executor.Executor(self.place)

self.inference_program = self.inference_program.clone(for_test=True)

def infer(self, inputs, return_numpy=True):
"""
:param inputs: a map of {"input_name": input_var} that will be feed into the inference program
Expand Down
4 changes: 2 additions & 2 deletions python/paddle/fluid/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ def __init__(self,
program_func_outs = train_func()
self.train_func_outputs = program_func_outs if isinstance(
program_func_outs, list) else [program_func_outs]
self.test_program = self.train_program.clone()
self.test_program = self.train_program.clone(for_test=True)

# The fisrt element of program_func_outs is loss.
# The first element of program_func_outs is loss.
loss = self.train_func_outputs[0]

optimizer = optimizer_func()
Expand Down