macrosynergy.learning.forecasting.torch.samplers#
- class TimeSeriesSampler(dataset, batch_size, shuffle=True, aggregate_last=True, drop_last=False)[source]#
Bases:
SamplerBatch sampler for datasets indexed by time, to ensure that batches are comprised of samples from contiguous time periods.
- Parameters:
dataset (torch.utils.data.Dataset) – The PyTorch dataset to sample from.
batch_size (int) – Number of samples per batch.
shuffle (bool, optional) – Whether to shuffle the order of batches. Default is True.
aggregate_last (bool, optional) – Whether to aggregate the last batch with the previous one if it has length smaller than batch_size. Default is True.
drop_last (bool, optional) – Whether to drop the last batch if it has length smaller than batch_size. Default is False.