mr2.nn.GEGLU

class mr2.nn.GEGLU[source]

Bases: Module

Gated linear unit activation function.

References

..[GLU] Shazeer, N. (2020). GLU variants improve transformer. https://arxiv.org/abs/2002.05202

__init__(n_channels_in: int, n_channels_out: int | None = None, features_last: bool = False)[source]

Initialize the GEGLU activation function.

Parameters:
  • n_channels_in (int) – The number of input features/channels.

  • n_channels_out (int | None, default: None) – The number of output features/channels. If None, the number of output features is the same as the number of input features.

  • features_last (bool, default: False) – If True, the channel dimension is the last dimension, else in the second dimension.

__call__(x: Tensor) → Tensor[source]

Apply the GEGLU activation.

Parameters:

x (Tensor) – Input tensor

Returns:

Activated tensor

forward(x: Tensor) → Tensor[source]

Apply the GEGLU activation.