Class StreamSampler#
Defined in File stream.h
Inheritance Relationships#
Base Type#
public torch::data::samplers::Sampler< BatchSize >(Template Class Sampler)
Class Documentation#
-
class StreamSampler : public torch::data::samplers::Sampler<BatchSize>#
A sampler for (potentially infinite) streams of data.
The major feature of the
StreamSampleris that it does not return particular indices, but instead only the number of elements to fetch from the dataset. The dataset has to decide how to produce those elements.Public Functions
-
explicit StreamSampler(size_t epoch_size)#
Constructs the
StreamSamplerwith the number of individual examples that should be fetched until the sampler is exhausted.
-
virtual void reset(std::optional<size_t> new_size = std::nullopt) override#
Resets the internal state of the sampler.
-
virtual std::optional<BatchSize> next(size_t batch_size) override#
Returns a
BatchSizeobject with the number of elements to fetch in the next batch.This number is the minimum of the supplied
batch_sizeand the difference between theepoch_sizeand the current index. If theepoch_sizehas been reached, returns an empty optional.
-
virtual void save(serialize::OutputArchive &archive) const override#
Serializes the
StreamSamplerto thearchive.
-
virtual void load(serialize::InputArchive &archive) override#
Deserializes the
StreamSamplerfrom thearchive.
-
explicit StreamSampler(size_t epoch_size)#