MCPcopy Create free account
hub / github.com/OpenImagingLab/FlashVSR / init_weights

Function init_weights

diffsynth/models/wan_video_text_encoder.py:192–206  ·  view source on GitHub ↗
(m)

Source from the content-addressed store, hash-verified

190 return rel_buckets
191
192def init_weights(m):
193 if isinstance(m, T5LayerNorm):
194 nn.init.ones_(m.weight)
195 elif isinstance(m, T5FeedForward):
196 nn.init.normal_(m.gate[0].weight, std=m.dim**-0.5)
197 nn.init.normal_(m.fc1.weight, std=m.dim**-0.5)
198 nn.init.normal_(m.fc2.weight, std=m.dim_ffn**-0.5)
199 elif isinstance(m, T5Attention):
200 nn.init.normal_(m.q.weight, std=(m.dim * m.dim_attn)**-0.5)
201 nn.init.normal_(m.k.weight, std=m.dim**-0.5)
202 nn.init.normal_(m.v.weight, std=m.dim**-0.5)
203 nn.init.normal_(m.o.weight, std=(m.num_heads * m.dim_attn)**-0.5)
204 elif isinstance(m, T5RelativeEmbedding):
205 nn.init.normal_(
206 m.embedding.weight, std=(2 * m.num_buckets * m.num_heads)**-0.5)
207
208
209class WanTextEncoder(torch.nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected