Caffe2 - C++ API
A deep learning, cross platform ML framework
Public Member Functions
torch::data::datasets::StatefulDataset< Self, Batch, BatchRequest > Class Template Referenceabstract

A stateful dataset is a dataset that maintains some internal state, which will be reset() at the beginning of each epoch. More...

#include <stateful.h>

Inheritance diagram for torch::data::datasets::StatefulDataset< Self, Batch, BatchRequest >:
torch::data::datasets::BatchDataset< Self, optional< Batch >, BatchRequest >

Public Member Functions

virtual void reset ()=0
 Resets internal state of the dataset.
 
- Public Member Functions inherited from torch::data::datasets::BatchDataset< Self, optional< Batch >, BatchRequest >
virtual optional< Batch > get_batch (BatchRequest request)=0
 Returns a batch of data given an index.
 
virtual optional< size_t > size () const =0
 Returns the size of the dataset, or an empty optional if it is unsized.
 
MapDataset< Self, TransformType > map (TransformType transform)&
 Creates a MapDataset that applies the given transform to this dataset.
 
MapDataset< Self, TransformType > map (TransformType transform)&&
 Creates a MapDataset that applies the given transform to this dataset.
 

Additional Inherited Members

- Public Types inherited from torch::data::datasets::BatchDataset< Self, optional< Batch >, BatchRequest >
using SelfType = Self
 
using BatchType = optional< Batch >
 
using BatchRequestType = BatchRequest
 
- Static Public Attributes inherited from torch::data::datasets::BatchDataset< Self, optional< Batch >, BatchRequest >
static constexpr bool is_stateful
 

Detailed Description

template<typename Self, typename Batch = std::vector<Example<>>, typename BatchRequest = size_t>
class torch::data::datasets::StatefulDataset< Self, 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 StatefulDataset specialization is automatically boxed into an optional for the datast's BatchType).

Definition at line 28 of file stateful.h.


The documentation for this class was generated from the following file: