From f2e1f3e1143a9231bbc642c98b22b6bae3f94096 Mon Sep 17 00:00:00 2001 From: guosheng Date: Mon, 15 Jan 2018 18:45:29 +0800 Subject: [PATCH] Fix activation for glu --- python/paddle/v2/fluid/nets.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/python/paddle/v2/fluid/nets.py b/python/paddle/v2/fluid/nets.py index d515429216..d60ae43675 100644 --- a/python/paddle/v2/fluid/nets.py +++ b/python/paddle/v2/fluid/nets.py @@ -106,9 +106,10 @@ def sequence_conv_pool(input, def glu(input, dim=-1): """ - The gated linear unit composed by split and elementwise multiplication. - Specifically, Split the input into two equal sized parts :math:`a` and - :math:`b` along the given dimension and then compute as following: + The gated linear unit composed by split, sigmoid activation and elementwise + multiplication. Specifically, Split the input into two equal sized parts + :math:`a` and :math:`b` along the given dimension and then compute as + following: .. math:: @@ -133,5 +134,6 @@ def glu(input, dim=-1): """ a, b = layers.split(input, num_or_sections=2, dim=dim) - out = layers.elementwise_mul(x=a, y=b) + act_b = layers.sigmoid(x=b) + out = layers.elementwise_mul(x=a, y=act_b) return out -- GitLab