Class DistributedRandomSampler¶
Defined in File distributed.h
Page Contents
Inheritance Relationships¶
Base Type¶
public torch::data::samplers::DistributedSampler<>
(Template Class DistributedSampler)
Class Documentation¶
-
class DistributedRandomSampler : public torch::data::samplers::DistributedSampler<>¶
Select samples randomly.
The sampling order is shuffled at each
reset()
call.Public Functions
-
DistributedRandomSampler(size_t size, size_t num_replicas = 1, size_t rank = 0, bool allow_duplicates = true)¶
-
virtual void reset(std::optional<size_t> new_size = std::nullopt) override¶
Resets the
DistributedRandomSampler
to a new set of indices.
-
virtual std::optional<std::vector<size_t>> next(size_t batch_size) override¶
Returns the next batch of indices.
-
virtual void save(serialize::OutputArchive &archive) const override¶
Serializes the
DistributedRandomSampler
to thearchive
.
-
virtual void load(serialize::InputArchive &archive) override¶
Deserializes the
DistributedRandomSampler
from thearchive
.
-
size_t index() const noexcept¶
Returns the current index of the
DistributedRandomSampler
.
-
DistributedRandomSampler(size_t size, size_t num_replicas = 1, size_t rank = 0, bool allow_duplicates = true)¶