提交 f2e1f3e1 编写于 作者: G guosheng

Fix activation for glu

上级 e7acf32c
...@@ -106,9 +106,10 @@ def sequence_conv_pool(input, ...@@ -106,9 +106,10 @@ def sequence_conv_pool(input,
def glu(input, dim=-1): def glu(input, dim=-1):
""" """
The gated linear unit composed by split and elementwise multiplication. The gated linear unit composed by split, sigmoid activation and elementwise
Specifically, Split the input into two equal sized parts :math:`a` and multiplication. Specifically, Split the input into two equal sized parts
:math:`b` along the given dimension and then compute as following: :math:`a` and :math:`b` along the given dimension and then compute as
following:
.. math:: .. math::
...@@ -133,5 +134,6 @@ def glu(input, dim=-1): ...@@ -133,5 +134,6 @@ def glu(input, dim=-1):
""" """
a, b = layers.split(input, num_or_sections=2, dim=dim) 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 return out
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册