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

Class series_decomp_multi

layers/Autoformer_EncDec.py:76–93  ·  view source on GitHub ↗

Series decomposition block

Source from the content-addressed store, hash-verified

74
75
76class 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
96class FourierDecomp(nn.Module):

Callers 4

__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected