MCPcopy Create free account
hub / github.com/MotrixLab/ViMoGen / __init__

Method __init__

models/transformer/wan/modules/t5.py:269–301  ·  view source on GitHub ↗
(self,
                 vocab,
                 dim,
                 dim_attn,
                 dim_ffn,
                 num_heads,
                 num_layers,
                 num_buckets,
                 shared_pos=True,
                 dropout=0.1)

Source from the content-addressed store, hash-verified

267class T5Encoder(nn.Module):
268
269 def __init__(self,
270 vocab,
271 dim,
272 dim_attn,
273 dim_ffn,
274 num_heads,
275 num_layers,
276 num_buckets,
277 shared_pos=True,
278 dropout=0.1):
279 super(T5Encoder, self).__init__()
280 self.dim = dim
281 self.dim_attn = dim_attn
282 self.dim_ffn = dim_ffn
283 self.num_heads = num_heads
284 self.num_layers = num_layers
285 self.num_buckets = num_buckets
286 self.shared_pos = shared_pos
287
288 # layers
289 self.token_embedding = vocab if isinstance(vocab, nn.Embedding) \
290 else nn.Embedding(vocab, dim)
291 self.pos_embedding = T5RelativeEmbedding(
292 num_buckets, num_heads, bidirectional=True) if shared_pos else None
293 self.dropout = nn.Dropout(dropout)
294 self.blocks = nn.ModuleList([
295 T5SelfAttention(dim, dim_attn, dim_ffn, num_heads, num_buckets,
296 shared_pos, dropout) for _ in range(num_layers)
297 ])
298 self.norm = T5LayerNorm(dim)
299
300 # initialize weights
301 self.apply(init_weights)
302
303 def forward(self, ids, mask=None):
304 x = self.token_embedding(ids)

Callers

nothing calls this directly

Calls 4

T5RelativeEmbeddingClass · 0.85
T5SelfAttentionClass · 0.85
T5LayerNormClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected