GLU

Contents

GLU#

class brainpy.dnn.GLU(dim=-1)[source]#

Applies the gated linear unit function \({GLU}(a, b)= a \otimes \sigma(b)\) where \(a\) is the first half of the input matrices and \(b\) is the second half.

Parameters:

dim (int) – the dimension on which to split the input. Default: -1

Shape:
  • Input: \((\ast_1, N, \ast_2)\) where * means, any number of additional dimensions

  • Output: \((\ast_1, M, \ast_2)\) where \(M=N/2\)

Examples:

>>> import brainpy as bp
>>> import brainpy.math as bm
>>> m = bp.dnn.GLU()
>>> input = bm.random.randn(4, 2)
>>> output = m(input)
update(input)[source]#

The function to specify the updating rule.

Return type:

TypeVar(ArrayType, Array, Variable, TrainVar, Array, ndarray)