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

Method __init__

diffplanner/models/rnns/t2m_bigru.py:50–59  ·  view source on GitHub ↗
(self, d_model, max_len=300)

Source from the content-addressed store, hash-verified

48class PositionalEncoding(nn.Module):
49
50 def __init__(self, d_model, max_len=300):
51 super(PositionalEncoding, self).__init__()
52
53 pe = torch.zeros(max_len, d_model)
54 position = torch.arange(0, max_len, dtype=torch.float).unsqueeze(1)
55 div_term = torch.exp(torch.arange(0, d_model, 2).float() * (-math.log(10000.0) / d_model))
56 pe[:, 0::2] = torch.sin(position * div_term)
57 pe[:, 1::2] = torch.cos(position * div_term)
58 # pe = pe.unsqueeze(0).transpose(0, 1)
59 self.register_buffer('pe', pe)
60
61 def forward(self, pos):
62 return self.pe[pos]

Callers

nothing calls this directly

Calls 1

__init__Method · 0.45

Tested by

no test coverage detected