pub struct Dataset { /* private fields */ }Expand description
A supervised dataset: inputs (X) and targets (Y).
Stored as contiguous buffers with row-major layout:
inputs.len() == len * input_dimtargets.len() == len * target_dim
Implementations§
Source§impl Dataset
impl Dataset
Sourcepub fn from_flat(
inputs: Vec<f32>,
targets: Vec<f32>,
input_dim: usize,
target_dim: usize,
) -> Result<Self>
pub fn from_flat( inputs: Vec<f32>, targets: Vec<f32>, input_dim: usize, target_dim: usize, ) -> Result<Self>
Build a dataset from flat buffers.
inputs is (len, input_dim) and targets is (len, target_dim).
Sourcepub fn from_rows(inputs: &[Vec<f32>], targets: &[Vec<f32>]) -> Result<Self>
pub fn from_rows(inputs: &[Vec<f32>], targets: &[Vec<f32>]) -> Result<Self>
Build a dataset from per-sample rows.
This is a convenience constructor (it copies into contiguous storage).
Sourcepub fn target_dim(&self) -> usize
pub fn target_dim(&self) -> usize
Returns the per-sample target dimension.
Sourcepub fn inputs_flat(&self) -> &[f32]
pub fn inputs_flat(&self) -> &[f32]
Returns the underlying contiguous inputs buffer.
Shape: (len * input_dim,).
Sourcepub fn targets_flat(&self) -> &[f32]
pub fn targets_flat(&self) -> &[f32]
Returns the underlying contiguous targets buffer.
Shape: (len * target_dim,).
Sourcepub fn input(&self, idx: usize) -> &[f32]
pub fn input(&self, idx: usize) -> &[f32]
Returns the idx-th input row (shape: (input_dim,)).
Panics if idx >= len.
Sourcepub fn target(&self, idx: usize) -> &[f32]
pub fn target(&self, idx: usize) -> &[f32]
Returns the idx-th target row (shape: (target_dim,)).
Panics if idx >= len.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Dataset
impl RefUnwindSafe for Dataset
impl Send for Dataset
impl Sync for Dataset
impl Unpin for Dataset
impl UnwindSafe for Dataset
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