From 3559e5a3fa0c494039d000b826d3ee5a9661be5e Mon Sep 17 00:00:00 2001 From: SunGaofeng Date: Tue, 11 Jun 2019 01:29:42 +0800 Subject: [PATCH] fix bug when iterate in locals_var.items() in python3 (#17948) test=develop --- python/paddle/fluid/layers/ops.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/python/paddle/fluid/layers/ops.py b/python/paddle/fluid/layers/ops.py index 47737f17d..6c944da56 100644 --- a/python/paddle/fluid/layers/ops.py +++ b/python/paddle/fluid/layers/ops.py @@ -89,7 +89,7 @@ def uniform_random(shape, dtype='float32', min=-1.0, max=1.0, seed=0): if not isinstance(dtype, core.VarDesc.VarType): dtype = convert_np_dtype_to_dtype_(dtype) - locals_var = locals() + locals_var = locals().copy() kwargs = dict() for name, val in locals_var.items(): if val is not None: @@ -103,7 +103,7 @@ _hard_shrink_ = generate_layer_fn('hard_shrink') def hard_shrink(x, threshold=None): - locals_var = locals() + locals_var = locals().copy() kwargs = dict() for name, val in locals_var.items(): if val is not None: @@ -124,7 +124,7 @@ _cum_sum_ = generate_layer_fn('cumsum') def cumsum(x, axis=None, exclusive=None, reverse=None): - locals_var = locals() + locals_var = locals().copy() kwargs = dict() for name, val in locals_var.items(): if val is not None: @@ -145,7 +145,7 @@ _thresholded_relu_ = generate_layer_fn('thresholded_relu') def thresholded_relu(x, threshold=None): - locals_var = locals() + locals_var = locals().copy() kwargs = dict() for name, val in locals_var.items(): if val is not None: -- GitLab