pub struct SamplerDataset<D, I> { /* private fields */ }Expand description
Sample items from a dataset.
This is an convenient way of modeling a dataset as a probability distribution of a fixed size. You have multiple options to instantiate the dataset sampler.
-
With replacement (Default): This is the most efficient way of using the sampler because no state is required to keep indices that have been selected.
-
Without replacement: This has a similar effect to using a shuffled dataset, but with more flexibility since you can set the dataset to an arbitrary size. Once every item has been used, a new cycle is created with a new random suffle.
Implementations§
source§impl<D, I> SamplerDataset<D, I>
impl<D, I> SamplerDataset<D, I>
sourcepub fn new(dataset: D, size: usize) -> SamplerDataset<D, I>
pub fn new(dataset: D, size: usize) -> SamplerDataset<D, I>
Creates a new sampler dataset with replacement.
sourcepub fn with_replacement(dataset: D, size: usize) -> SamplerDataset<D, I>
pub fn with_replacement(dataset: D, size: usize) -> SamplerDataset<D, I>
Creates a new sampler dataset with replacement.
sourcepub fn without_replacement(dataset: D, size: usize) -> SamplerDataset<D, I>
pub fn without_replacement(dataset: D, size: usize) -> SamplerDataset<D, I>
Creates a new sampler dataset without replacement.
Trait Implementations§
source§impl<D, I> Dataset<I> for SamplerDataset<D, I>
impl<D, I> Dataset<I> for SamplerDataset<D, I>
Auto Trait Implementations§
impl<D, I> RefUnwindSafe for SamplerDataset<D, I>where
D: RefUnwindSafe,
I: RefUnwindSafe,
impl<D, I> Send for SamplerDataset<D, I>
impl<D, I> Sync for SamplerDataset<D, I>
impl<D, I> Unpin for SamplerDataset<D, I>
impl<D, I> UnwindSafe for SamplerDataset<D, I>where
D: UnwindSafe,
I: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more