MCPcopy Create free account
hub / github.com/MarkFzp/act-plus-plus / __init__

Method __init__

train_actuator_network.py:253–261  ·  view source on GitHub ↗
(self, d_model: int, dropout: float = 0.1, max_len: int = 5000)

Source from the content-addressed store, hash-verified

251
252class PositionalEncoding(nn.Module):
253 def __init__(self, d_model: int, dropout: float = 0.1, max_len: int = 5000):
254 super().__init__()
255 self.dropout = nn.Dropout(p=dropout)
256 position = torch.arange(max_len).unsqueeze(1)
257 div_term = torch.exp(torch.arange(0, d_model, 2) * (-math.log(10000.0) / d_model))
258 pe = torch.zeros(max_len, 1, d_model)
259 pe[:, 0, 0::2] = torch.sin(position * div_term)
260 pe[:, 0, 1::2] = torch.cos(position * div_term)
261 self.register_buffer('pe', pe)
262
263 def forward(self, x):
264 """

Callers

nothing calls this directly

Calls 1

__init__Method · 0.45

Tested by

no test coverage detected