MCPcopy Create free account
hub / github.com/BorealisAI/scaleformer / TokenEmbedding

Class TokenEmbedding

layers/Embed.py:55–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53 return self.pe[:, scale:x.size(1)*scale+1:scale]
54
55class TokenEmbedding(nn.Module):
56 def __init__(self, c_in, d_model):
57 super(TokenEmbedding, self).__init__()
58 padding = 1 if torch.__version__ >= '1.5.0' else 2
59 self.tokenConv = nn.Conv1d(in_channels=c_in, out_channels=d_model,
60 kernel_size=3, padding=padding, padding_mode='circular', bias=False)
61 for m in self.modules():
62 if isinstance(m, nn.Conv1d):
63 nn.init.kaiming_normal_(m.weight, mode='fan_in', nonlinearity='leaky_relu')
64
65 def forward(self, x):
66 x = self.tokenConv(x.permute(0, 2, 1)).transpose(1, 2)
67 return x
68
69
70class FixedEmbedding(nn.Module):

Callers 3

__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected