Template Class Sampler#
Defined in File base.h
Page Contents
Inheritance Relationships#
Derived Types#
public torch::data::samplers::RandomSampler(Class RandomSampler)public torch::data::samplers::SequentialSampler(Class SequentialSampler)
Class Documentation#
-
template<typename BatchRequest = std::vector<size_t>>
class Sampler# A
Sampleris an object that yields an index with which to access a dataset.Subclassed by torch::data::samplers::RandomSampler, torch::data::samplers::SequentialSampler
Public Types
-
using BatchRequestType = BatchRequest#
Public Functions
-
virtual ~Sampler() = default#
-
virtual void reset(std::optional<size_t> new_size) = 0#
Resets the
Sampler’s internal state.Typically called before a new epoch. Optionally, accepts a new size when resetting the sampler.
-
virtual std::optional<BatchRequest> next(size_t batch_size) = 0#
Returns the next index if possible, or an empty optional if the sampler is exhausted for this epoch.
-
virtual void save(serialize::OutputArchive &archive) const = 0#
Serializes the
Samplerto thearchive.
-
virtual void load(serialize::InputArchive &archive) = 0#
Deserializes the
Samplerfrom thearchive.
-
using BatchRequestType = BatchRequest#