| 157 | |
| 158 | |
| 159 | def forward(self, x, |
| 160 | edge_index: torch.LongTensor, |
| 161 | edge_weight: torch.FloatTensor) -> Tensor: # x: [bs x nvars x patch_len x patch_num] |
| 162 | |
| 163 | n_vars = x.shape[1] |
| 164 | # Input encoding |
| 165 | x = x.permute(0,1,3,2) # x: [bs x nvars x patch_num x patch_len] |
| 166 | x = self.W_P(x) # x: [bs x nvars x patch_num x d_model] |
| 167 | |
| 168 | u = torch.reshape(x, (x.shape[0]*x.shape[1],x.shape[2],x.shape[3])) # u: [bs * nvars x patch_num x d_model] |
| 169 | u = self.dropout(u + self.W_pos) # u: [bs * nvars x patch_num x d_model] |
| 170 | |
| 171 | # Encoder |
| 172 | z = self.encoder(u, edge_index, edge_weight) # z: [bs * nvars x patch_num x d_model] |
| 173 | z = torch.reshape(z, (-1,n_vars,z.shape[-2],z.shape[-1])) # z: [bs x nvars x patch_num x d_model] |
| 174 | z = z.permute(0,1,3,2) # z: [bs x nvars x d_model x patch_num] |
| 175 | |
| 176 | return z |
| 177 | |
| 178 | |
| 179 | |