Пример #1
0
 def forward(self, size):
     if size.dim() == 2:
         size = size.unsqueeze(-1)
     log_size = torch.log(size)
     cube_log_size = torch.pow(log_size, 3)
     # input order in calc_residual is x,then y
     residual = forecast_residual3d(log_size, cube_log_size, window_train=self._window_train, window_test=self._window_test,keep_first_train_nan=True)
     return residual.squeeze(-1).transpose(0,1)
Пример #2
0
 def forward(self, tensor_x, tensor_y):
     if tensor_x.dim() < tensor_y.dim():
         tensor_x = tensor_x.expand_as(tensor_y)
     residual = forecast_residual3d(tensor_x,
                                    tensor_y,
                                    window_train=self._window_train,
                                    window_test=self._window_test,
                                    keep_first_train_nan=True)
     residual = residual.squeeze(-1).transpose(0, 1)
     return tsf.rolling_cumulation(data_ts=residual, window=self._window)
Пример #3
0
 def forward(self, tensor_x, tensor_y):
     if tensor_x.dim() < tensor_y.dim():
         tensor_x = tensor_x.expand_as(tensor_y)
     residual = forecast_residual3d(tensor_x,
                                    tensor_y,
                                    window_train=self._window_train,
                                    window_test=self._window_test,
                                    keep_first_train_nan=True)
     residual = residual.squeeze(-1).transpose(0, 1)
     return tsf.rolling_weighted_std(residual,
                                     window=self._window,
                                     halflife=self._halflife)
Пример #4
0
 def forward(self, tensor_x, tensor_y):
     if tensor_x.dim() < tensor_y.dim():
         tensor_x = tensor_x.expand_as(tensor_y)
     residual = forecast_residual3d(tensor_x,
                                    tensor_y,
                                    window_train=self._window_train,
                                    window_test=self._window_test,
                                    keep_first_train_nan=True)
     residual = residual.squeeze(-1).transpose(0, 1)
     varmom = tsf.rolling_mean_(
         residual, window=self._window) / tsf.rolling_std_dof_0(
             residual, window=self._window)
     return varmom
Пример #5
0
 def forward(self, tensor_x, tensor_y, benchmark=None):
     import torch
     if tensor_x.dim() < tensor_y.dim():
         tensor_x = tensor_x.expand_as(tensor_y)
     residual = forecast_residual3d(tensor_x,
                                    tensor_y,
                                    window_train=self._window_train,
                                    window_test=self._window_test,
                                    keep_first_train_nan=True)
     residual = residual.squeeze(-1).transpose(0, 1)
     if benchmark is None:
         benchmark = torch.zeros_like(residual)
     return tsf.rolling_upside_std(tensor=residual,
                                   tensor_benchmark=benchmark,
                                   window=self._window)