Template Class StatefulDataset¶
Defined in File stateful.h
Batch= std::vector<Example<>>, typename
StatefulDataset: public torch::data::datasets::BatchDataset<Self, optional<Batch>, BatchRequest>¶
A stateful dataset is a dataset that maintains some internal state, which will be
reset()at the beginning of each epoch.
Subclasses can override the
reset()method to configure this behavior. Further, the return type of a stateful dataset’s
get_batch()method is always an
optional. When the stateful dataset wants to indicate to the dataloader that its epoch has ended, it should return an empty optional. The dataloader knows to modify its implementation based on whether the dataset is stateless or stateful.
Note that when subclassing a from
StatefulDataset<Self, T>, the return type of
get_batch(), which the subclass must override, will be
optional<T>(i.e. the type specified in the
StatefulDatasetspecialization is automatically boxed into an
optionalfor the dataset’s