Series decomposition block
| 74 | |
| 75 | |
| 76 | class series_decomp_multi(nn.Module): |
| 77 | """ |
| 78 | Series decomposition block |
| 79 | """ |
| 80 | def __init__(self, kernel_size): |
| 81 | super(series_decomp_multi, self).__init__() |
| 82 | self.moving_avg = [moving_avg(kernel, stride=1) for kernel in kernel_size] |
| 83 | self.layer = torch.nn.Linear(1, len(kernel_size)) |
| 84 | |
| 85 | def forward(self, x): |
| 86 | moving_mean=[] |
| 87 | for func in self.moving_avg: |
| 88 | moving_avg = func(x) |
| 89 | moving_mean.append(moving_avg.unsqueeze(-1)) |
| 90 | moving_mean=torch.cat(moving_mean,dim=-1) |
| 91 | moving_mean = torch.sum(moving_mean*nn.Softmax(-1)(self.layer(x.unsqueeze(-1))),dim=-1) |
| 92 | res = x - moving_mean |
| 93 | return res, moving_mean |
| 94 | |
| 95 | |
| 96 | class FourierDecomp(nn.Module): |