A sampler for (potentially infinite) streams of data. More...
#include <stream.h>
Public Member Functions | |
TORCH_API | StreamSampler (size_t epoch_size) |
Constructs the StreamSampler with the number of individual examples that should be fetched until the sampler is exhausted. More... | |
TORCH_API void | reset (optional< size_t > new_size=nullopt) override |
Resets the internal state of the sampler. | |
TORCH_API optional< BatchSize > | next (size_t batch_size) override |
Returns a BatchSize object with the number of elements to fetch in the next batch. More... | |
TORCH_API void | save (serialize::OutputArchive &archive) const override |
Serializes the StreamSampler to the archive . | |
TORCH_API void | load (serialize::InputArchive &archive) override |
Deserializes the StreamSampler from the archive . | |
Additional Inherited Members | |
Public Types inherited from torch::data::samplers::Sampler< BatchSize > | |
using | BatchRequestType = 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.
|
explicit |
Constructs the StreamSampler
with the number of individual examples that should be fetched until the sampler is exhausted.
Definition at line 21 of file stream.cpp.
|
overridevirtual |
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 the epoch_size
and the current index. If the epoch_size
has been reached, returns an empty optional.
Implements torch::data::samplers::Sampler< BatchSize >.
Definition at line 30 of file stream.cpp.