pub struct Sample { /* private fields */ }Expand description
A single training sample - a named collection of data buffers.
Implementations§
Source§impl Sample
impl Sample
Sourcepub fn with(self, name: &str, tensor: Tensor) -> Sample
pub fn with(self, name: &str, tensor: Tensor) -> Sample
Add a named tensor to this sample (builder pattern).
Sourcepub fn with_metadata(self, source: impl Into<String>, index: u64) -> Sample
pub fn with_metadata(self, source: impl Into<String>, index: u64) -> Sample
Attach metadata to this sample.
Sourcepub fn get_mut(&mut self, name: &str) -> Option<&mut Tensor>
pub fn get_mut(&mut self, name: &str) -> Option<&mut Tensor>
Get a mutable reference to a tensor by name.
Sourcepub fn insert(&mut self, name: impl Into<String>, tensor: Tensor)
pub fn insert(&mut self, name: impl Into<String>, tensor: Tensor)
Insert a tensor with the given name.
Sourcepub fn remove(&mut self, name: &str) -> Option<Tensor>
pub fn remove(&mut self, name: &str) -> Option<Tensor>
Remove a field by name, returning the tensor if it existed.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&str, &Tensor)>
pub fn iter(&self) -> impl Iterator<Item = (&str, &Tensor)>
Iterate over all (name, tensor) pairs.
Sourcepub fn metadata(&self) -> Option<&SampleMetadata>
pub fn metadata(&self) -> Option<&SampleMetadata>
Get the metadata, if any.
Sourcepub fn field_names(&self) -> impl Iterator<Item = &str>
pub fn field_names(&self) -> impl Iterator<Item = &str>
Names of all fields in this sample.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Sample
impl RefUnwindSafe for Sample
impl Send for Sample
impl Sync for Sample
impl Unpin for Sample
impl UnsafeUnpin for Sample
impl UnwindSafe for Sample
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