glu

paddle.fluid.nets. glu ( input, dim=- 1 ) [source]

Warning: API “paddle.fluid.nets.glu” is deprecated since 2.0.0, and will be removed in future versions. Please use “paddle.nn.functional.glu” instead.

api_attr

Static Graph

The Gated Linear Units(GLU) composed by api_fluid_layers_split , api_fluid_layers_sigmoid and api_fluid_layers_elementwise_mul . Specifically, GLU will plit the input into two equal-sized parts, \(a\) and \(b\), along the given dimension and then compute as following:

\[{GLU}(a, b)= a \otimes \sigma(b)\]

Refer to Language Modeling with Gated Convolutional Networks.

Args:
input (Variable): The input variable which is a Tensor or LoDTensor.

The supported data types include float32, float64 and float16 (only for GPU).

dim (int, optional): The dimension along which to split. If \(dim < 0\), the

dimension to split along is \(rank(input) + dim\). Default -1.

Returns:

Variable: Variable with half the size and same data type of input.

Examples:
import paddle.fluid as fluid
import paddle
paddle.enable_static()

data = fluid.data(
    name="words", shape=[-1, 6, 3, 9], dtype="float32")
# shape of output: [-1, 3, 3, 9]
output = fluid.nets.glu(input=data, dim=1)