Skip to content

Commit 6f32e02

Browse files
authored
Update dctnet.py
1 parent 9e7ef6d commit 6f32e02

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

layers/dctnet.py

+11-15
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def dct(x, norm=None):
5151
return V
5252

5353

54-
# class dct_channel_block(nn.Module):
54+
# class senet_block(nn.Module):
5555
# def __init__(self, channel=512, ratio=1):
5656
# super(dct_channel_block, self).__init__()
5757
# self.avg_pool = nn.AdaptiveAvgPool1d(1) #innovation
@@ -64,13 +64,12 @@ def dct(x, norm=None):
6464

6565
# def forward(self, x):
6666
# # b, c, l = x.size() # (B,C,L)
67-
# # y = self.avg_pool(x) # (B,C,L) 通过avg=》 (B,C,1)
67+
# # y = self.avg_pool(x) # (B,C,L) -> (B,C,1)
6868
# # print("y",y.shape)
6969
# x = x.permute(0,2,1)
7070
# b, c, l = x.size()
71-
# y = self.avg_pool(x).view(b, c) # (B,C,L) 通过avg=》 (B,C,1)
71+
# y = self.avg_pool(x).view(b, c) # (B,C,L) ->(B,C,1)
7272
# # print("y",y.shape)
73-
# #为了丢给Linear学习,需要view把数据展平开
7473
# # y = self.fc(y).view(b, c, 96)
7574

7675
# y = self.fc(y).view(b,c,1)
@@ -88,26 +87,25 @@ def __init__(self, channel):
8887
nn.Linear( channel*2, channel, bias=False),
8988
nn.Sigmoid()
9089
)
91-
# self.dct_norm = nn.LayerNorm([512], eps=1e-6)#作为模块一般normal channel效果好点 for traffic
90+
# self.dct_norm = nn.LayerNorm([512], eps=1e-6)
9291

9392
self.dct_norm = nn.LayerNorm([96], eps=1e-6)#for lstm on length-wise
9493
# self.dct_norm = nn.LayerNorm([36], eps=1e-6)#for lstm on length-wise on ill with input =36
9594

9695

9796
def forward(self, x):
9897
b, c, l = x.size() # (B,C,L) (32,96,512)
99-
# y = self.avg_pool(x) # (B,C,L) 通过avg=》 (B,C,1)
98+
# y = self.avg_pool(x) # (B,C,L) -> (B,C,1)
10099

101-
# y = self.avg_pool(x).view(b, c) # (B,C,L) 通过avg=》 (B,C,1)
102-
# print("y",y.shape)
103-
#为了丢给Linear学习,需要view把数据展平开
100+
# y = self.avg_pool(x).view(b, c) # (B,C,L) -> (B,C,1)
101+
# print("y",y.shape
104102
# y = self.fc(y).view(b, c, 96)
105103
list = []
106-
for i in range(c):#i represent channel ,分别对channel的数据做dct
104+
for i in range(c):
107105
freq=dct(x[:,i,:])
108106
# print("freq-shape:",freq.shape)
109107
list.append(freq)
110-
##把dct结果进行拼接,再进行频率特征学习
108+
111109

112110

113111
stack_dct=torch.stack(list,dim=1)
@@ -116,9 +114,9 @@ def forward(self, x):
116114
for traffic mission:f_weight = self.dct_norm(f_weight.permute(0,2,1))#matters for traffic datasets
117115
'''
118116

119-
lr_weight = self.dct_norm(stack_dct) #不一定要,lstm用的时候不加
117+
lr_weight = self.dct_norm(stack_dct)
120118
lr_weight = self.fc(stack_dct)
121-
lr_weight = self.dct_norm(lr_weight) #不一定要,lstm用的时候不加
119+
lr_weight = self.dct_norm(lr_weight)
122120

123121
# print("lr_weight",lr_weight.shape)
124122
return x *lr_weight #result
@@ -131,6 +129,4 @@ def forward(self, x):
131129
result = dct_model.forward(tensor)
132130
print("result.shape:",result.shape)
133131

134-
#Informer channel*2
135-
#
136132

0 commit comments

Comments
 (0)