pytorch_forecasting.data.samplers.TimeSynchronizedBatchSampler#
- class pytorch_forecasting.data.samplers.TimeSynchronizedBatchSampler(sampler: Sampler, batch_size: int = 64, shuffle: bool = False, drop_last: bool = False)[source]#
Samples mini-batches randomly but in a time-synchronised manner.
Time-synchornisation means that the time index of the first decoder samples are aligned across the batch. This sampler does not support missing values in the dataset.
Initialize.
- Parameters:
sampler (Sampler or Iterable) – Base sampler. Can be any iterable object.
drop_last (bool) – If
True, drop last mini-batch from a group if it is smaller thanbatch_size. Default isFalse.shuffle (bool) – If
True, shuffle dataset. Default isFalse.batch_size (int) – Number of samples in a mini-batch. This is rather the maximum number of samples. Because mini-batches are grouped by prediction time, chances are that there are multiple where batch size will be smaller than the maximum. Default is 64.
- __init__(sampler: Sampler, batch_size: int = 64, shuffle: bool = False, drop_last: bool = False)#
Initialize.
- Parameters:
sampler (Sampler or Iterable) – Base sampler. Can be any iterable object.
drop_last (bool) – If
True, drop last mini-batch from a group if it is smaller thanbatch_size. Default isFalse.shuffle (bool) – If
True, shuffle dataset. Default isFalse.batch_size (int) – Number of samples in a mini-batch. This is rather the maximum number of samples. Because mini-batches are grouped by prediction time, chances are that there are multiple where batch size will be smaller than the maximum. Default is 64.
Methods
__class_getitem__Parameterizes a generic class.
__delattr__(name, /)Implement delattr(self, name).
__dir__()Default dir() implementation.
__eq__(value, /)Return self==value.
__format__(format_spec, /)Default object formatter.
__ge__(value, /)Return self>=value.
__getattribute__(name, /)Return getattr(self, name).
__getstate__()Helper for pickle.
__gt__(value, /)Return self>value.
__hash__()Return hash(self).
__init_subclass__Function to initialize subclasses.
__iter__()__le__(value, /)Return self<=value.
__len__()__lt__(value, /)Return self<value.
__ne__(value, /)Return self!=value.
__new__(*args, **kwargs)__reduce__()Helper for pickle.
__reduce_ex__(protocol, /)Helper for pickle.
__repr__()Return repr(self).
__setattr__(name, value, /)Implement setattr(self, name, value).
__sizeof__()Size of object in memory, in bytes.
__str__()Return str(self).
__subclasshook__Abstract classes can override this to customize issubclass().
construct_batch_groups(groups)Construct index of batches from which can be sampled
get_groups(sampler)Create the groups which can be sampled.
Attributes
__annotations____dict____doc____module____orig_bases____parameters____weakref__list of weak references to the object