lgatr.layers.mlp.nonlinearities.ScalarGatedNonlinearity
- class lgatr.layers.mlp.nonlinearities.ScalarGatedNonlinearity(nonlinearity='gelu')[source]
Bases:
ModuleGated nonlinearity on multivectors.
Given multivector input
x, computesf(x_0) * x, wherefis one of ReLU, sigmoid, tanh, GeLU, or SiLU. Auxiliary scalar inputs are processed with the samefdirectly (without gating).- Parameters:
nonlinearity (
str) – Non-linearity type. One of"relu","sigmoid","tanh","gelu","silu".
- forward(multivectors, scalars=None)[source]
Apply the gated nonlinearity.
- Parameters:
multivectors (
Tensor) – Input multivectors of shape(..., 16).scalars (
Tensor|None) – Optional input scalars of shape(..., s_channels). If None,outputs_sis None.
- Return type:
tuple[Tensor,Tensor|None]- Returns:
outputs_mv – Output multivectors of shape
(..., 16).outputs_s – Output scalars of shape
(..., s_channels), or None ifscalarsis None.