Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Facebookresearch Audiocraft GLU Activations

From Leeroopedia
Knowledge Sources
Domains Neural_Networks, Activations
Last Updated 2026-02-14 01:00 GMT

Overview

Concrete tool for custom Gated Linear Unit activation variants and a factory helper function for use in AudioCraft neural network modules.

Description

This module defines CustomGLU variants (SiGLU, ReGLU, GeGLU) that apply gating with different activation functions (Sigmoid, ReLU, GELU). The get_activation_fn factory function instantiates activations by name, supporting both standard PyTorch activations and the custom GLU variants.

Usage

Import get_activation_fn when configuring activation functions for transformer or codec modules by name string.

Code Reference

Source Location

Signature

class CustomGLU(nn.Module):
    def __init__(self, activation: nn.Module, dim: int = -1): ...
    def forward(self, x: torch.Tensor) -> torch.Tensor: ...

def get_activation_fn(activation: str) -> tp.Union[str, tp.Callable]:
    """Return activation function by name: 'relu', 'gelu', 'siglu', 'reglu', 'geglu'."""

Import

from audiocraft.modules.activations import get_activation_fn

I/O Contract

Inputs

Name Type Required Description
activation str Yes Activation name ('relu', 'gelu', 'siglu', 'reglu', 'geglu')

Outputs

Name Type Description
activation_fn Callable Activation function or module

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment