Skip to content

Commit cb6b468

Browse files
authored
Merge pull request #7535 from guoshengCS/add-glu-act
Add activation for glu
2 parents e7acf32 + f2e1f3e commit cb6b468

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

python/paddle/v2/fluid/nets.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,10 @@ def sequence_conv_pool(input,
106106

107107
def glu(input, dim=-1):
108108
"""
109-
The gated linear unit composed by split and elementwise multiplication.
110-
Specifically, Split the input into two equal sized parts :math:`a` and
111-
:math:`b` along the given dimension and then compute as following:
109+
The gated linear unit composed by split, sigmoid activation and elementwise
110+
multiplication. Specifically, Split the input into two equal sized parts
111+
:math:`a` and :math:`b` along the given dimension and then compute as
112+
following:
112113
113114
.. math::
114115
@@ -133,5 +134,6 @@ def glu(input, dim=-1):
133134
"""
134135

135136
a, b = layers.split(input, num_or_sections=2, dim=dim)
136-
out = layers.elementwise_mul(x=a, y=b)
137+
act_b = layers.sigmoid(x=b)
138+
out = layers.elementwise_mul(x=a, y=act_b)
137139
return out

0 commit comments

Comments
 (0)