MCPcopy Create free account
hub / github.com/TencentARC/BrushNet / __init__

Method __init__

src/diffusers/models/normalization.py:154–176  ·  view source on GitHub ↗
(
        self,
        embedding_dim: int,
        conditioning_embedding_dim: int,
        # NOTE: It is a bit weird that the norm layer can be configured to have scale and shift parameters
        # because the output is immediately scaled and shifted by the projected conditioning embeddings.
        # Note that AdaLayerNorm does not let the norm layer have scale and shift parameters.
        # However, this is how it was implemented in the original code, and it's rather likely you should
        # set `elementwise_affine` to False.
        elementwise_affine=True,
        eps=1e-5,
        bias=True,
        norm_type="layer_norm",
    )

Source from the content-addressed store, hash-verified

152
153class AdaLayerNormContinuous(nn.Module):
154 def __init__(
155 self,
156 embedding_dim: int,
157 conditioning_embedding_dim: int,
158 # NOTE: It is a bit weird that the norm layer can be configured to have scale and shift parameters
159 # because the output is immediately scaled and shifted by the projected conditioning embeddings.
160 # Note that AdaLayerNorm does not let the norm layer have scale and shift parameters.
161 # However, this is how it was implemented in the original code, and it's rather likely you should
162 # set `elementwise_affine` to False.
163 elementwise_affine=True,
164 eps=1e-5,
165 bias=True,
166 norm_type="layer_norm",
167 ):
168 super().__init__()
169 self.silu = nn.SiLU()
170 self.linear = nn.Linear(conditioning_embedding_dim, embedding_dim * 2, bias=bias)
171 if norm_type == "layer_norm":
172 self.norm = LayerNorm(embedding_dim, eps, elementwise_affine, bias)
173 elif norm_type == "rms_norm":
174 self.norm = RMSNorm(embedding_dim, eps, elementwise_affine)
175 else:
176 raise ValueError(f"unknown norm_type {norm_type}")
177
178 def forward(self, x: torch.Tensor, conditioning_embedding: torch.Tensor) -> torch.Tensor:
179 emb = self.linear(self.silu(conditioning_embedding))

Callers

nothing calls this directly

Calls 3

LayerNormClass · 0.85
RMSNormClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected