From b05c253cacd2d984e786a566fcef3725efeb2497 Mon Sep 17 00:00:00 2001 From: fengjiayi Date: Tue, 26 Dec 2017 14:42:06 +0800 Subject: [PATCH] fix an error --- python/paddle/v2/fluid/backward.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/paddle/v2/fluid/backward.py b/python/paddle/v2/fluid/backward.py index 2254652e8f..9bc3e73f59 100644 --- a/python/paddle/v2/fluid/backward.py +++ b/python/paddle/v2/fluid/backward.py @@ -53,7 +53,8 @@ def _is_all_in_set_(cands, s): def _strip_grad_suffix_(name): - return name[:name.find(core.grad_var_suffix())] + pos = name.find(core.grad_var_suffix()) + return name[:pos] if pos != -1 else name def _append_grad_suffix_(name): @@ -139,7 +140,7 @@ def _append_backward_ops_(target, to_insert = [] for idx, op_desc in enumerate(grad_op_descs): for arg in op_desc.input_arg_names(): - if arg in no_grad_set[block.idx]: + if core.grad_var_suffix() in arg and arg in no_grad_set[block.idx]: to_insert.append((arg, idx)) for ele in reversed(to_insert): arg = ele[0] -- GitLab