pub trait Sampler: Send {
type Iter: Iterator<Item = usize> + Send;
// Required methods
fn iter(&self) -> Self::Iter;
fn len(&self) -> usize;
// Provided methods
fn is_empty(&self) -> bool { ... }
fn into_batch_sampler(
self,
batch_size: usize,
drop_last: bool,
) -> BatchingSampler<Self>
where Self: Sized { ... }
fn into_distributed(
self,
num_replicas: usize,
rank: usize,
) -> DistributedWrapper<Self>
where Self: Sized { ... }
}Expand description
Unified trait for sampling from a dataset
This trait provides a consistent interface for both individual sample and batch sampling strategies.
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn into_batch_sampler(
self,
batch_size: usize,
drop_last: bool,
) -> BatchingSampler<Self>where
Self: Sized,
fn into_batch_sampler(
self,
batch_size: usize,
drop_last: bool,
) -> BatchingSampler<Self>where
Self: Sized,
Convert this sampler into a batch sampler
Sourcefn into_distributed(
self,
num_replicas: usize,
rank: usize,
) -> DistributedWrapper<Self>where
Self: Sized,
fn into_distributed(
self,
num_replicas: usize,
rank: usize,
) -> DistributedWrapper<Self>where
Self: Sized,
Create a distributed version of this sampler
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".