pub struct ClassificationDatasetBuilder<C: Class> { /* private fields */ }
Expand description
A builder for ClassificationDataset
.
Implementations§
Source§impl<C: Class> ClassificationDatasetBuilder<C>
impl<C: Class> ClassificationDatasetBuilder<C>
Sourcepub fn add(&mut self, input: impl Into<Box<[f32]>>, class: C)
pub fn add(&mut self, input: impl Into<Box<[f32]>>, class: C)
Adds a pair of input and class to the dataset.
§Example
let mut dataset = ClassificationDatasetBuilder::new();
dataset.add(vec![1.0, 2.0, 3.0, 4.0], MyClass::Person);
dataset.add(vec![4.0, 3.0, 2.0, 1.0], MyClass::Thing);
Sourcepub fn build(self, dev: &Device) -> Result<ClassificationDataset>
pub fn build(self, dev: &Device) -> Result<ClassificationDataset>
Builds the dataset and copies the data to the device passed in.
§Example
let dev = candle_core::Device::Cpu;
let mut dataset = ClassificationDatasetBuilder::new();
dataset.add(vec![1.0, 2.0, 3.0, 4.0], MyClass::Person);
dataset.add(vec![4.0, 3.0, 2.0, 1.0], MyClass::Thing);
let dataset = dataset.build(&dev).unwrap();
Trait Implementations§
Auto Trait Implementations§
impl<C> Freeze for ClassificationDatasetBuilder<C>
impl<C> RefUnwindSafe for ClassificationDatasetBuilder<C>where
C: RefUnwindSafe,
impl<C> Send for ClassificationDatasetBuilder<C>where
C: Send,
impl<C> Sync for ClassificationDatasetBuilder<C>where
C: Sync,
impl<C> Unpin for ClassificationDatasetBuilder<C>where
C: Unpin,
impl<C> UnwindSafe for ClassificationDatasetBuilder<C>where
C: 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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more