Skip to main content

DataLoaderBuilder

Struct DataLoaderBuilder 

Source
pub struct DataLoaderBuilder<B: Backend, I, O> { /* private fields */ }
Available on crate features std and dataset only.
Expand description

A builder for data loaders.

Implementations§

Source§

impl<B, I, O> DataLoaderBuilder<B, I, O>
where B: Backend, I: Send + Sync + Clone + Debug + 'static, O: Send + Clone + Debug + 'static,

Source

pub fn new<Bt>(batcher: Bt) -> Self
where Bt: Batcher<B, I, O> + 'static,

Creates a new data loader builder.

§Arguments
  • batcher - The batcher.
§Returns

The data loader builder.

Source

pub fn batch_size(self, batch_size: usize) -> Self

Sets the batch size to a fix number.

The fix batch strategy will be used.

§Arguments
  • batch_size - The batch size.
§Returns

The data loader builder.

Source

pub fn shuffle(self, seed: u64) -> Self

Sets the seed for shuffling.

Each time the dataloader starts a new iteration, the dataset will be shuffled.

§Arguments
  • seed - The seed.
§Returns

The data loader builder.

Source

pub fn num_workers(self, num_workers: usize) -> Self

Sets the number of workers.

  • Some(0) or None: the dataloader will run without work threads.
  • Some(n); n > 0: the dataloader will run with n background threads.

A 1-worker threaded dataloader will run loads in a background thread, while a 0-worker threaded dataloader will run loads in the main thread.

§Arguments
  • num_workers - The number of workers.
§Returns

The data loader builder.

Source

pub fn set_device(self, device: B::Device) -> Self

Sets the data loader device.

§Arguments
  • device - The device to use when loading a batch.
§Returns

The data loader builder.

Source

pub fn build<D>(self, dataset: D) -> Arc<dyn DataLoader<B, O>>
where D: Dataset<I> + 'static,

Builds the data loader.

§Arguments
  • dataset - The dataset.
§Returns

The data loader.

Auto Trait Implementations§

§

impl<B, I, O> Freeze for DataLoaderBuilder<B, I, O>
where <B as Backend>::Device: Freeze,

§

impl<B, I, O> !RefUnwindSafe for DataLoaderBuilder<B, I, O>

§

impl<B, I, O> Send for DataLoaderBuilder<B, I, O>

§

impl<B, I, O> Sync for DataLoaderBuilder<B, I, O>

§

impl<B, I, O> Unpin for DataLoaderBuilder<B, I, O>
where <B as Backend>::Device: Unpin,

§

impl<B, I, O> !UnwindSafe for DataLoaderBuilder<B, I, O>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V