pub struct DefaultConverter;Expand description
Applies DefaultConvert in no-auto-batching mode.
§Examples
use rusttorch_data::{Bytes, Collate, CollateError, DefaultConverter};
let mut converter = DefaultConverter;
assert_eq!(converter.convert(vec![1_i64, 2])?, [1, 2]);
assert_eq!(
converter.convert(Some(Bytes(vec![3, 4])))?,
Some(Bytes(vec![3, 4])),
);
// The `Collate` adapter accepts the loader's one-sample no-batch group.
assert_eq!(converter.collate(vec![vec![5_i64, 6]])?, [5, 6]);Implementations§
Source§impl DefaultConverter
impl DefaultConverter
Sourcepub fn convert<T>(&mut self, sample: T) -> Result<T::Output, CollateError>where
T: DefaultConvert,
pub fn convert<T>(&mut self, sample: T) -> Result<T::Output, CollateError>where
T: DefaultConvert,
Converts one sample without adding a batch dimension.
Trait Implementations§
Source§impl Checkpointable for DefaultConverter
impl Checkpointable for DefaultConverter
Source§fn save_state(&self) -> Self::State
fn save_state(&self) -> Self::State
Captures the current component state.
Source§fn validate_state(&self, _state: &Self::State) -> Result<()>
fn validate_state(&self, _state: &Self::State) -> Result<()>
Checks state compatibility without mutating the component.
Source§fn load_validated(&mut self, _state: &Self::State)
fn load_validated(&mut self, _state: &Self::State)
Restores state previously accepted by
Self::validate_state.Source§impl Clone for DefaultConverter
impl Clone for DefaultConverter
Source§impl<Sample> Collate<Sample> for DefaultConverterwhere
Sample: DefaultConvert,
impl<Sample> Collate<Sample> for DefaultConverterwhere
Sample: DefaultConvert,
impl Copy for DefaultConverter
Source§impl Debug for DefaultConverter
impl Debug for DefaultConverter
Auto Trait Implementations§
impl Forget for DefaultConverter
impl Freeze for DefaultConverter
impl RefUnwindSafe for DefaultConverter
impl Send for DefaultConverter
impl Sync for DefaultConverter
impl Unpin for DefaultConverter
impl UnsafeUnpin for DefaultConverter
impl UnwindSafe for DefaultConverter
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