model.dataloader
save_normalization
def save_normalization(train_dir: str | Path, data_train: np.ndarray) -> dict
Compute the model input normalization from the training data and save it to seq_mean.npy and seq_std.npy in train_dir, overwriting existing files.
Returns
dict: Normalization statistics, with float values under the keysmeanandstd.
load_normalization
def load_normalization(train_dir: str | Path) -> tuple[float, float]
Load the model input normalization (mean, std) saved with the training data. Training and inference both use these values.
SEQUENCE_DATASET Objects
class SEQUENCE_DATASET(Dataset)
__init__
def __init__(path_to_file: str,
data: str,
train: bool,
temporal_window: int,
samples_per_epoch: Optional[int] = None,
**kwargs) -> None
Initialize the Sequence Dataset. Normalizes the data with the statistics saved by create_trainset at:
- project_name/
- data/
- train/
- seq_mean.npy
- seq_std.npy
- train/
Parameters
- path_to_file (
str): Path to the dataset files. - data (
str): Name of the data file. - train (
bool): Flag indicating whether it's training data. - temporal_window (
int): Size of the temporal window.
Returns
None
__len__
def __len__() -> int
Return the number of data points.
Returns
int: Number of data points.
__getitem__
def __getitem__(index: int) -> torch.Tensor
Get a normalized sequence at the specified index.
Parameters
- index (
int): Index of the item.
Returns
torch.Tensor: Normalized sequence data at the specified index.