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

Method __init__

models/transformer/wan/modules/t5.py:317–349  ·  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

315class T5Decoder(nn.Module):
316
317 def __init__(self,
318 vocab,
319 dim,
320 dim_attn,
321 dim_ffn,
322 num_heads,
323 num_layers,
324 num_buckets,
325 shared_pos=True,
326 dropout=0.1):
327 super(T5Decoder, self).__init__()
328 self.dim = dim
329 self.dim_attn = dim_attn
330 self.dim_ffn = dim_ffn
331 self.num_heads = num_heads
332 self.num_layers = num_layers
333 self.num_buckets = num_buckets
334 self.shared_pos = shared_pos
335
336 # layers
337 self.token_embedding = vocab if isinstance(vocab, nn.Embedding) \
338 else nn.Embedding(vocab, dim)
339 self.pos_embedding = T5RelativeEmbedding(
340 num_buckets, num_heads, bidirectional=False) if shared_pos else None
341 self.dropout = nn.Dropout(dropout)
342 self.blocks = nn.ModuleList([
343 T5CrossAttention(dim, dim_attn, dim_ffn, num_heads, num_buckets,
344 shared_pos, dropout) for _ in range(num_layers)
345 ])
346 self.norm = T5LayerNorm(dim)
347
348 # initialize weights
349 self.apply(init_weights)
350
351 def forward(self, ids, mask=None, encoder_states=None, encoder_mask=None):
352 b, s = ids.size()

Callers

nothing calls this directly

Calls 4

T5RelativeEmbeddingClass · 0.85
T5CrossAttentionClass · 0.85
T5LayerNormClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected