pub struct DefaultCollator;Expand description
Applies DefaultCollate to an owned group of samples.
§Examples
use rusttorch_core::{Kind, Tensor};
use rusttorch_data::{Bytes, Collate, CollateError, DefaultCollator};
let mut collator = DefaultCollator;
let numbers: Tensor = collator.collate(vec![1_i64, 2])?;
assert_eq!(numbers.kind(), Kind::Int64);
assert_eq!(numbers.size(), [2]);
let tensors = collator.collate(vec![
Tensor::from_slice(&[1_i64, 2]),
Tensor::from_slice(&[3_i64, 4]),
])?;
assert_eq!(tensors.size(), [2, 2]);
let nested: (Tensor, Vec<Bytes>) = collator.collate(vec![
(1_i64, Bytes(vec![1, 2])),
(2_i64, Bytes(vec![3])),
])?;
assert_eq!(nested.0.size(), [2]);
assert_eq!(nested.1, [Bytes(vec![1, 2]), Bytes(vec![3])]);Trait Implementations§
Source§impl Checkpointable for DefaultCollator
impl Checkpointable for DefaultCollator
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 DefaultCollator
impl Clone for DefaultCollator
Source§impl<Sample> Collate<Sample> for DefaultCollatorwhere
Sample: DefaultCollate,
impl<Sample> Collate<Sample> for DefaultCollatorwhere
Sample: DefaultCollate,
impl Copy for DefaultCollator
Source§impl Debug for DefaultCollator
impl Debug for DefaultCollator
Auto Trait Implementations§
impl Forget for DefaultCollator
impl Freeze for DefaultCollator
impl RefUnwindSafe for DefaultCollator
impl Send for DefaultCollator
impl Sync for DefaultCollator
impl Unpin for DefaultCollator
impl UnsafeUnpin for DefaultCollator
impl UnwindSafe for DefaultCollator
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