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

Method __init__

models/transformer/wan/modules/t2m_model.py:494–504  ·  view source on GitHub ↗
(self, d_model, max_len=5000)

Source from the content-addressed store, hash-verified

492
493class PositionalEncoding(nn.Module):
494 def __init__(self, d_model, max_len=5000):
495 super(PositionalEncoding, self).__init__()
496
497 pe = torch.zeros(max_len, d_model)
498 position = torch.arange(0, max_len, dtype=torch.float).unsqueeze(1)
499 div_term = torch.exp(torch.arange(0, d_model, 2).float() * (-np.log(10000.0) / d_model))
500 pe[:, 0::2] = torch.sin(position * div_term)
501 pe[:, 1::2] = torch.cos(position * div_term)
502 pe = pe.unsqueeze(0).transpose(0, 1)
503
504 self.register_buffer('pe', pe)
505
506 def forward(self, x):
507 # x: [B, T, C]

Callers

nothing calls this directly

Calls 2

logMethod · 0.80
__init__Method · 0.45

Tested by

no test coverage detected