diff --git a/python/paddle/v2/fluid/layers/nn.py b/python/paddle/v2/fluid/layers/nn.py index 7feb479d2e3bc396eac53045888175ba54864b66..180a760150b19bee201b9e2cc6cb91dda2cf1f2a 100644 --- a/python/paddle/v2/fluid/layers/nn.py +++ b/python/paddle/v2/fluid/layers/nn.py @@ -816,6 +816,11 @@ def sequence_pool(input, pool_type, **kwargs): "MaxIndex": max_index}, attrs={"pooltype": pool_type.upper()}) + # when pool_type is max, variable max_index is initialized, + # so we stop the gradient explicitly here + if pool_type == 'max': + max_index.stop_gradient = True + return pool_out