From cf028885acbb23815264e4e14d16c992f0ea05eb Mon Sep 17 00:00:00 2001 From: Guo Sheng Date: Mon, 27 Apr 2020 22:53:04 +0800 Subject: [PATCH] Fix dygraph dropout seed. test=release/2.0 (#24199) --- python/paddle/fluid/layers/nn.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/python/paddle/fluid/layers/nn.py b/python/paddle/fluid/layers/nn.py index 5b28f141d3d..d497662f190 100644 --- a/python/paddle/fluid/layers/nn.py +++ b/python/paddle/fluid/layers/nn.py @@ -868,12 +868,11 @@ def dropout(x, if (seed is None or seed == 0) and default_main_program().random_seed != 0: seed = default_main_program().random_seed - seed = seed if seed is not None else 0 _is_test = not _dygraph_tracer()._train_mode - out, mask = core.ops.dropout(x, 'dropout_prob', dropout_prob, 'is_test', - _is_test, 'fix_seed', seed is not None, - 'seed', seed, 'dropout_implementation', - dropout_implementation) + out, mask = core.ops.dropout( + x, 'dropout_prob', dropout_prob, 'is_test', _is_test, 'fix_seed', + seed is not None, 'seed', seed if seed is not None else 0, + 'dropout_implementation', dropout_implementation) return out helper = LayerHelper('dropout', **locals()) -- GitLab