Shortcuts

Template Class Sampler

Inheritance Relationships

Derived Type

Class Documentation

template<typename BatchRequest = std::vector<size_t>>
class torch::data::samplers::Sampler

A Sampler is an object that yields an index with which to access a dataset.

Subclassed by torch::data::samplers::DistributedSampler< BatchRequest >

Public Types

using BatchRequestType = BatchRequest

Public Functions

~Sampler() = default
void reset(optional<size_t> new_size) = 0

Resets the Sampler’s internal state.

Typically called before a new epoch. Optionally, accepts a new size when reseting the sampler.

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.

void save(serialize::OutputArchive &archive) const = 0

Serializes the Sampler to the archive.

void load(serialize::InputArchive &archive) = 0

Deserializes the Sampler from the archive.

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources