* update EasyAnimateV2 * update datasets loader * update datasets loader * update fast api * complete data preprocess pipeline. * update lots of readme * update readme bans * fix bug in validation while training * provide example for video cut * update text box * add arxiv * delete IDDPM * update gallery * update arxiv * update readme * update readme * link fix * update vae readme --------- Co-authored-by: zouxinyi0625 <zouxinyi.zxy@alibaba-inc.com>
28 lines
615 B
Python
Executable File
28 lines
615 B
Python
Executable File
import torch.nn as nn
|
|
|
|
ACTIVATION_FUNCTIONS = {
|
|
"elu": nn.ELU(),
|
|
"swish": nn.SiLU(),
|
|
"silu": nn.SiLU(),
|
|
"mish": nn.Mish(),
|
|
"gelu": nn.GELU(),
|
|
"relu": nn.ReLU(),
|
|
}
|
|
|
|
|
|
def get_activation(act_fn: str) -> nn.Module:
|
|
"""Helper function to get activation function from string.
|
|
|
|
Args:
|
|
act_fn (str): Name of activation function.
|
|
|
|
Returns:
|
|
nn.Module: Activation function.
|
|
"""
|
|
|
|
act_fn = act_fn.lower()
|
|
if act_fn in ACTIVATION_FUNCTIONS:
|
|
return ACTIVATION_FUNCTIONS[act_fn]
|
|
else:
|
|
raise ValueError(f"Unsupported activation function: {act_fn}")
|