MCPcopy Create free account
hub / github.com/PKU-YuanGroup/MagicTime / __init__

Method __init__

utils/unet_blocks.py:694–707  ·  view source on GitHub ↗
(
        self, 
        d_model, 
        dropout = 0., 
        max_len = 24
    )

Source from the content-addressed store, hash-verified

692
693class PositionalEncoding(nn.Module):
694 def __init__(
695 self,
696 d_model,
697 dropout = 0.,
698 max_len = 24
699 ):
700 super().__init__()
701 self.dropout = nn.Dropout(p=dropout)
702 position = torch.arange(max_len).unsqueeze(1)
703 div_term = torch.exp(torch.arange(0, d_model, 2) * (-math.log(10000.0) / d_model))
704 pe = torch.zeros(1, max_len, d_model)
705 pe[0, :, 0::2] = torch.sin(position * div_term)
706 pe[0, :, 1::2] = torch.cos(position * div_term)
707 self.register_buffer('pe', pe)
708
709 def forward(self, x):
710 x = x + self.pe[:, :x.size(1)]

Callers

nothing calls this directly

Calls 1

__init__Method · 0.45

Tested by

no test coverage detected