MCPcopy Create free account
hub / github.com/Anoise/WTFlib / Encoder

Class Encoder

LDPS_Graph/layers/Autoformer_EncDec.py:101–128  ·  view source on GitHub ↗

Autoformer encoder

Source from the content-addressed store, hash-verified

99
100
101class Encoder(nn.Module):
102 """
103 Autoformer encoder
104 """
105 def __init__(self, attn_layers, conv_layers=None, norm_layer=None):
106 super(Encoder, self).__init__()
107 self.attn_layers = nn.ModuleList(attn_layers)
108 self.conv_layers = nn.ModuleList(conv_layers) if conv_layers is not None else None
109 self.norm = norm_layer
110
111 def forward(self, x, attn_mask=None):
112 attns = []
113 if self.conv_layers is not None:
114 for attn_layer, conv_layer in zip(self.attn_layers, self.conv_layers):
115 x, attn = attn_layer(x, attn_mask=attn_mask)
116 x = conv_layer(x)
117 attns.append(attn)
118 x, attn = self.attn_layers[-1](x)
119 attns.append(attn)
120 else:
121 for attn_layer in self.attn_layers:
122 x, attn = attn_layer(x, attn_mask=attn_mask)
123 attns.append(attn)
124
125 if self.norm is not None:
126 x = self.norm(x)
127
128 return x, attns
129
130
131class DecoderLayer(nn.Module):

Callers 3

__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected