Update modeling_super_linear.py
Browse files199 unmodified lines2002012022032032042052063 unmodified lines2102112122132132142152166 unmodified lines2232242252262272282262292302312322332342352362372272392402412282292304 unmodified lines235236237252238239240241199 unmodified lines self.revin_layer = RevIN(num_features = None, affine=False, norm_type = None, subtract_last = False) self.zero_shot_Linear = None
def transform_model(self,x,new_lookback,mode): def transform_model(self,new_lookback,mode): if mode == 1: W = self.Linear.weight.detach() new_W = W[:, -new_lookback:] 3 unmodified lines new_W = new_W * final_scaling
self.zero_shot_Linear = new_W elif mode ==2: else: W = self.Linear.weight.detach() W4d = W.unsqueeze(0).unsqueeze(0) # (1, 1, out, in)
6 unmodified lines )[0, 0] # drop the two singleton dims
self.zero_shot_Linear = new_W # shape (self.horizon, new_lookback) else: W = self.Linear.weight.detach() # (out_features, seq_len) W4d = W.unsqueeze(0).unsqueeze(0) # (1, 1, out, in)
# resize H → self.horizon and W → new_lookback new_W = F.interpolate( W4d, size=(self.horizon, new_lookback), # (H_out, W_out) mode='bilinear', align_corners=False )[0, 0] # drop the two singleton dims
x = F.linear(x, new_W) self.zero_shot_Linear = W return x
4 unmodified lines #if self.zero_shot_Linear is None: #print(F"new Lookkback : {x.shape[1]}") x = self.transform_model(x,x.shape[1],3) x = self.transform_model(x.shape[1],3)
x = x.clone() #x = x * (x.shape[1]/512)modeling_super_linear.py+4-18