espnet2.enh.layers.ncsnpp_utils.layers.get_act
Less than 1 minute
espnet2.enh.layers.ncsnpp_utils.layers.get_act
espnet2.enh.layers.ncsnpp_utils.layers.get_act(config)
Get activation functions based on the specified configuration.
This function returns a corresponding activation function from the PyTorch library based on the input string configuration. Supported activation functions include ELU, ReLU, Leaky ReLU, and Swish. If an unsupported configuration is provided, a NotImplementedError is raised.
- Parameters:config (str) – The name of the activation function to retrieve. Supported values are “elu”, “relu”, “lrelu”, and “swish”.
- Returns: The corresponding activation function as a PyTorch module.
- Return type: nn.Module
- Raises:NotImplementedError – If the specified activation function is not supported.
Examples
>>> act_fn = get_act("relu")
>>> print(act_fn)
ReLU()
>>> act_fn = get_act("swish")
>>> print(act_fn)
SiLU()
>>> act_fn = get_act("unknown")
Traceback (most recent call last):
...
NotImplementedError: activation function does not exist!