Class StreamSampler
Defined in File stream.h
Page Contents
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
StreamSampler
is 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
StreamSampler
with 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
BatchSize
object with the number of elements to fetch in the next batch.This number is the minimum of the supplied
batch_size
and the difference between theepoch_size
and the current index. If theepoch_size
has been reached, returns an empty optional.
-
virtual void save(serialize::OutputArchive &archive) const override
Serializes the
StreamSampler
to thearchive
.
-
virtual void load(serialize::InputArchive &archive) override
Deserializes the
StreamSampler
from thearchive
.
-
explicit StreamSampler(size_t epoch_size)