Caffe2 - C++ API
A deep learning, cross platform ML framework
Public Member Functions
torch::data::samplers::StreamSampler Class Reference

A sampler for (potentially infinite) streams of data. More...

#include <stream.h>

Inheritance diagram for torch::data::samplers::StreamSampler:
torch::data::samplers::Sampler< BatchSize >

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< BatchSizenext (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
 

Detailed Description

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.

Definition at line 35 of file stream.h.

Constructor & Destructor Documentation

torch::data::samplers::StreamSampler::StreamSampler ( size_t  epoch_size)
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.

Member Function Documentation

optional< BatchSize > torch::data::samplers::StreamSampler::next ( size_t  batch_size)
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.


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