DeepTime icon indicating copy to clipboard operation
DeepTime copied to clipboard

def __getitem__(self, idx: int) -> Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]:

Open YHU11 opened this issue 9 months ago • 0 comments

def __getitem__(self, idx: int) -> Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]:
    if self.time_features:
        dim_idx = idx // self.n_time_samples
        dim_slice = slice(dim_idx, dim_idx + 1)
        idx = idx % self.n_time_samples
    else:
        dim_slice = slice(None)

    x_start = idx
    x_end = x_start + self.lookback_len
    y_start = x_end - self.lookback_aux_len
    y_end = y_start + self.lookback_aux_len + self.horizon_len

    x = self.data_x[x_start:x_end, dim_slice]
    y = self.data_y[y_start:y_end, dim_slice]
    x_time = self.timestamps[x_start:x_end]
    y_time = self.timestamps[y_start:y_end]

    return x, y, x_time, y_time
    
    
    Hello, thank you for sharing the code. I would like to ask why this place retrieves data in this way

123

YHU11 avatar May 17 '24 05:05 YHU11