@@ -51,7 +51,7 @@ def dct(x, norm=None):
51
51
return V
52
52
53
53
54
- # class dct_channel_block (nn.Module):
54
+ # class senet_block (nn.Module):
55
55
# def __init__(self, channel=512, ratio=1):
56
56
# super(dct_channel_block, self).__init__()
57
57
# self.avg_pool = nn.AdaptiveAvgPool1d(1) #innovation
@@ -64,13 +64,12 @@ def dct(x, norm=None):
64
64
65
65
# def forward(self, x):
66
66
# # 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)
68
68
# # print("y",y.shape)
69
69
# x = x.permute(0,2,1)
70
70
# 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)
72
72
# # print("y",y.shape)
73
- # #为了丢给Linear学习,需要view把数据展平开
74
73
# # y = self.fc(y).view(b, c, 96)
75
74
76
75
# y = self.fc(y).view(b,c,1)
@@ -88,26 +87,25 @@ def __init__(self, channel):
88
87
nn .Linear ( channel * 2 , channel , bias = False ),
89
88
nn .Sigmoid ()
90
89
)
91
- # self.dct_norm = nn.LayerNorm([512], eps=1e-6)#作为模块一般normal channel效果好点 for traffic
90
+ # self.dct_norm = nn.LayerNorm([512], eps=1e-6)
92
91
93
92
self .dct_norm = nn .LayerNorm ([96 ], eps = 1e-6 )#for lstm on length-wise
94
93
# self.dct_norm = nn.LayerNorm([36], eps=1e-6)#for lstm on length-wise on ill with input =36
95
94
96
95
97
96
def forward (self , x ):
98
97
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)
100
99
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
104
102
# y = self.fc(y).view(b, c, 96)
105
103
list = []
106
- for i in range (c ):#i represent channel ,分别对channel的数据做dct
104
+ for i in range (c ):
107
105
freq = dct (x [:,i ,:])
108
106
# print("freq-shape:",freq.shape)
109
107
list .append (freq )
110
- ##把dct结果进行拼接,再进行频率特征学习
108
+
111
109
112
110
113
111
stack_dct = torch .stack (list ,dim = 1 )
@@ -116,9 +114,9 @@ def forward(self, x):
116
114
for traffic mission:f_weight = self.dct_norm(f_weight.permute(0,2,1))#matters for traffic datasets
117
115
'''
118
116
119
- lr_weight = self .dct_norm (stack_dct ) #不一定要,lstm用的时候不加
117
+ lr_weight = self .dct_norm (stack_dct )
120
118
lr_weight = self .fc (stack_dct )
121
- lr_weight = self .dct_norm (lr_weight ) #不一定要,lstm用的时候不加
119
+ lr_weight = self .dct_norm (lr_weight )
122
120
123
121
# print("lr_weight",lr_weight.shape)
124
122
return x * lr_weight #result
@@ -131,6 +129,4 @@ def forward(self, x):
131
129
result = dct_model .forward (tensor )
132
130
print ("result.shape:" ,result .shape )
133
131
134
- #Informer channel*2
135
- #
136
132
0 commit comments