提交 626922d3 编写于 作者: L Lfc1993 提交者: Tao Luo

fix run_time_error in uniform_random. test=develop (#17152)

fix runtimeerror : dictionary changed size during iteration when calling uniform_random in python3+
上级 deb510d4
...@@ -86,12 +86,11 @@ def uniform_random(shape, dtype='float32', min=-1.0, max=1.0, seed=0): ...@@ -86,12 +86,11 @@ def uniform_random(shape, dtype='float32', min=-1.0, max=1.0, seed=0):
result = fluid.layers.uniform_random(shape=[32, 784]) result = fluid.layers.uniform_random(shape=[32, 784])
""" """
locals_var = locals().keys() locals_var = locals()
if not isinstance(dtype, core.VarDesc.VarType): if not isinstance(dtype, core.VarDesc.VarType):
dtype = convert_np_dtype_to_dtype_(dtype) dtype = convert_np_dtype_to_dtype_(dtype)
kwargs = dict() kwargs = dict()
for name in locals_var: for name, val in locals_var.items():
val = locals()[name]
if val is not None: if val is not None:
kwargs[name] = val kwargs[name] = val
return _uniform_random_(**kwargs) return _uniform_random_(**kwargs)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册