MCPcopy Create free account
hub / github.com/Francis-Rings/MotionFollower / __init__

Method __init__

src/models/motion_module.py:262–272  ·  view source on GitHub ↗
(self, d_model, dropout=0.0, max_len=24)

Source from the content-addressed store, hash-verified

260
261class PositionalEncoding(nn.Module):
262 def __init__(self, d_model, dropout=0.0, max_len=24):
263 super().__init__()
264 self.dropout = nn.Dropout(p=dropout)
265 position = torch.arange(max_len).unsqueeze(1)
266 div_term = torch.exp(
267 torch.arange(0, d_model, 2) * (-math.log(10000.0) / d_model)
268 )
269 pe = torch.zeros(1, max_len, d_model)
270 pe[0, :, 0::2] = torch.sin(position * div_term)
271 pe[0, :, 1::2] = torch.cos(position * div_term)
272 self.register_buffer("pe", pe)
273
274 def forward(self, x):
275 x = x + self.pe[:, : x.size(1)]

Callers 4

__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected