Autoformer encoder
| 218 | |
| 219 | |
| 220 | class Decoder(nn.Module): |
| 221 | """ |
| 222 | Autoformer encoder |
| 223 | """ |
| 224 | def __init__(self, layers, norm_layer=None, projection=None): |
| 225 | super(Decoder, self).__init__() |
| 226 | self.layers = nn.ModuleList(layers) |
| 227 | self.norm = norm_layer |
| 228 | self.projection = projection |
| 229 | |
| 230 | def forward(self, x, cross, x_mask=None, cross_mask=None, trend=None): |
| 231 | for layer in self.layers: |
| 232 | x, residual_trend = layer(x, cross, x_mask=x_mask, cross_mask=cross_mask) |
| 233 | trend = trend + residual_trend |
| 234 | |
| 235 | if self.norm is not None: |
| 236 | x = self.norm(x) |
| 237 | |
| 238 | if self.projection is not None: |
| 239 | x = self.projection(x) |
| 240 | return x, trend |