MCPcopy Create free account
hub / github.com/Francis-Rings/FlashPortrait / __init__

Method __init__

wan/models/wan_image_encoder.py:160–186  ·  view source on GitHub ↗
(self,
                 dim,
                 mlp_ratio,
                 num_heads,
                 activation='gelu',
                 proj_dropout=0.0,
                 norm_eps=1e-5)

Source from the content-addressed store, hash-verified

158class AttentionPool(nn.Module):
159
160 def __init__(self,
161 dim,
162 mlp_ratio,
163 num_heads,
164 activation='gelu',
165 proj_dropout=0.0,
166 norm_eps=1e-5):
167 assert dim % num_heads == 0
168 super().__init__()
169 self.dim = dim
170 self.mlp_ratio = mlp_ratio
171 self.num_heads = num_heads
172 self.head_dim = dim // num_heads
173 self.proj_dropout = proj_dropout
174 self.norm_eps = norm_eps
175
176 # layers
177 gain = 1.0 / math.sqrt(dim)
178 self.cls_embedding = nn.Parameter(gain * torch.randn(1, 1, dim))
179 self.to_q = nn.Linear(dim, dim)
180 self.to_kv = nn.Linear(dim, dim * 2)
181 self.proj = nn.Linear(dim, dim)
182 self.norm = LayerNorm(dim, eps=norm_eps)
183 self.mlp = nn.Sequential(
184 nn.Linear(dim, int(dim * mlp_ratio)),
185 QuickGELU() if activation == 'quick_gelu' else nn.GELU(),
186 nn.Linear(int(dim * mlp_ratio), dim), nn.Dropout(proj_dropout))
187
188 def forward(self, x):
189 """

Callers

nothing calls this directly

Calls 3

LayerNormClass · 0.85
QuickGELUClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected