Update modeling_super_linear.py
Browse files510 unmodified lines5115125135145155165175185195201 unmodified line5225235245255265275285295305315325335345355365375385395405415425435445455465471 unmodified line549550551530531552532553554535555556557558539540541542543544545559560561562563564565566567568569570510 unmodified lines
def forward(self, x_enc, x_mark_enc=None, x_dec=None, x_mark_dec=None, mask=None, freq=[None], get_prob=False):
if inf_pred_len is None: inf_pred_len = self.inf_pred_len
if len(x_enc.shape) > 2: x = x_enc.permute(0, 2, 1) B, V, L = x.shape1 unmodified line x = x_enc B, L = x.shape V = 1
short_lookback = False if L < self.seq_len: # print("test!") #ceil - very bad heuristic! scale_factor = self.seq_len / L scale_factor = int(np.ceil(scale_factor)) orig_pred_len = inf_pred_len
inf_pred_len = inf_pred_len*scale_factor x = interpolate(x_enc.permute(0, 2, 1), scale_factor=scale_factor, mode='linear')
x = x[:,: , -self.seq_len:] orig_L = L L = self.seq_len
short_lookback = True x = x.reshape(B * V, L) expert_probs = None if get_prob:1 unmodified line else: out, self.moe_loss = self.moe(x)
if self.auto_regressive and self.max_horizon < self.inf_pred_len: if self.auto_regressive and self.max_horizon < inf_pred_len: #print("bitch") outputs = [out] ar_x = torch.cat([x, out], dim=1)[:, -self.seq_len:] for i in range(0, self.inf_pred_len, self.max_horizon): for i in range(0, inf_pred_len, self.max_horizon): ar_out, _ = self.moe(ar_x) outputs.append(ar_out) ar_x = torch.cat([ar_x, ar_out], dim=1)[:, -self.seq_len:] out = torch.cat(outputs, dim=1)[:, :self.inf_pred_len] if len(x_enc.shape) > 2: out = out.reshape(B, V, out.shape[-1]) result = out.permute(0, 2, 1) else: result = out out = torch.cat(outputs, dim=1)[:,:inf_pred_len] out = out.reshape(B, V, out.shape[-1])
if short_lookback: out = interpolate(out, scale_factor=1/scale_factor, mode='linear') # print(out.shape) out = out[:, :,:orig_pred_len] result = out.permute(0, 2, 1) if get_prob: expert_probs = expert_probs.reshape(B, V, expert_probs.shape[-1]) return result, expert_probsmodeling_super_linear.py+32-11