MCPcopy Create free account
hub / github.com/NeuSpeech/EEG-To-Text / __init__

Method __init__

model_decoding.py:205–215  ·  view source on GitHub ↗
(self, d_model, dropout=0.1, max_len=5000)

Source from the content-addressed store, hash-verified

203class PositionalEncoding(nn.Module):
204
205 def __init__(self, d_model, dropout=0.1, max_len=5000):
206 super(PositionalEncoding, self).__init__()
207 self.dropout = nn.Dropout(p=dropout)
208
209 pe = torch.zeros(max_len, d_model)
210 position = torch.arange(0, max_len, dtype=torch.float).unsqueeze(1)
211 div_term = torch.exp(torch.arange(0, d_model, 2).float() * (-math.log(10000.0) / d_model))
212 pe[:, 0::2] = torch.sin(position * div_term)
213 pe[:, 1::2] = torch.cos(position * div_term)
214 pe = pe.unsqueeze(0).transpose(0, 1)
215 self.register_buffer('pe', pe)
216
217 def forward(self, x):
218 # print('[DEBUG] input size:', x.size())

Callers

nothing calls this directly

Calls 1

__init__Method · 0.45

Tested by

no test coverage detected