Diffusers
加入 Hugging Face 社区
并获得增强的文档体验
激活函数
用于支持 🤗 Diffusers 中各种模型的自定义激活函数。
GELU
class diffusers.models.activations.GELU
< 来源 > ( dim_in: int dim_out: int approximate: str = 'none' bias: bool = True )
参数
- dim_in (
int
) — 输入通道数。 - dim_out (
int
) — 输出通道数。 - approximate (
str
, 可选, 默认为 "none"
) — 如果为 "tanh"
,则使用 tanh 近似。 - bias (
bool
, 默认为 True) — 是否在线性层中使用偏置。
支持 tanh 近似(通过 approximate="tanh"
)的 GELU 激活函数。
GEGLU
class diffusers.models.activations.GEGLU
< 来源 > ( dim_in: int dim_out: int bias: bool = True )
参数
- dim_in (
int
) — 输入通道数。 - dim_out (
int
) — 输出通道数。 - bias (
bool
, 默认为 True) — 是否在线性层中使用偏置。
门控线性单元激活函数的一个 变体。
ApproximateGELU
class diffusers.models.activations.ApproximateGELU
< 来源 > ( dim_in: int dim_out: int bias: bool = True )
参数
- dim_in (
int
) — 输入通道数。 - dim_out (
int
) — 输出通道数。 - bias (
bool
, 默认为 True) — 是否在线性层中使用偏置。
高斯误差线性单元 (GELU) 的近似形式。更多细节请参见此 论文 的第 2 节。
SwiGLU
class diffusers.models.activations.SwiGLU
< 来源 > ( dim_in: int dim_out: int bias: bool = True )
参数
- dim_in (
int
) — 输入通道数。 - dim_out (
int
) — 输出通道数。 - bias (
bool
, 默认为 True) — 是否在线性层中使用偏置。
门控线性单元激活函数的一个 变体。它类似于 GEGLU
,但使用 SiLU / Swish 而非 GeLU。
FP32SiLU
class diffusers.models.activations.FP32SiLU
< 来源 > ( )
SiLU 激活函数,输入上转为 torch.float32。
LinearActivation
class diffusers.models.activations.LinearActivation
< 来源 > ( dim_in: int dim_out: int bias: bool = True activation: str = 'silu' )
< > 在 GitHub 上更新
© . This site is unofficial and not affiliated with Hugging Face, Inc.