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§fn clone(&self) -> DefaultConverter
fn clone(&self) -> DefaultConverter
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§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
Source§impl Default for DefaultConverter
impl Default for DefaultConverter
Source§fn default() -> DefaultConverter
fn default() -> DefaultConverter
Returns the “default value” for a type. Read more
Auto Trait Implementations§
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