MCPcopy Create free account
hub / github.com/MeiGen-AI/MultiTalk / __init__

Method __init__

wan/modules/clip.py:158–184  ·  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

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

Callers

nothing calls this directly

Calls 3

QuickGELUClass · 0.85
LayerNormClass · 0.70
__init__Method · 0.45

Tested by

no test coverage detected