Autoformer encoder
| 151 | |
| 152 | |
| 153 | class Decoder(nn.Module): |
| 154 | """ |
| 155 | Autoformer encoder |
| 156 | """ |
| 157 | def __init__(self, layers, norm_layer=None, projection=None): |
| 158 | super(Decoder, self).__init__() |
| 159 | self.layers = nn.ModuleList(layers) |
| 160 | self.norm = norm_layer |
| 161 | self.projection = projection |
| 162 | |
| 163 | def forward(self, x, cross, x_mask=None, cross_mask=None, trend=None): |
| 164 | for layer in self.layers: |
| 165 | x, residual_trend = layer(x, cross, x_mask=x_mask, cross_mask=cross_mask) |
| 166 | trend = trend + residual_trend |
| 167 | |
| 168 | if self.norm is not None: |
| 169 | x = self.norm(x) |
| 170 | |
| 171 | if self.projection is not None: |
| 172 | x = self.projection(x) |
| 173 | return x, trend |