MCPcopy Create free account
hub / github.com/DSL-Lab/StreamSplat / __init__

Method __init__

model/transformer_utils.py:363–370  ·  view source on GitHub ↗
(self, max_len, d_model)

Source from the content-addressed store, hash-verified

361
362class SinusoidalPositionalEncoding(nn.Module):
363 def __init__(self, max_len, d_model):
364 super().__init__()
365 pe = torch.zeros(max_len, d_model)
366 position = torch.arange(0, max_len, dtype=torch.float).unsqueeze(1)
367 div_term = torch.exp(torch.arange(0, d_model, 2, dtype=torch.float) * (-math.log(10000.0) / d_model))
368 pe[:, 0::2] = torch.sin(position * div_term)
369 pe[:, 1::2] = torch.cos(position * div_term)
370 self.register_buffer('pe', pe)
371
372 def forward(self, x):
373 seq_len = x.size(1)

Callers

nothing calls this directly

Calls 1

__init__Method · 0.45

Tested by

no test coverage detected