pub struct MnistDataset { /* private fields */ }Expand description
A loaded MNIST dataset stored entirely in memory.
Images are stored as Vec<u8> (28×28 = 784 bytes each).
Labels are u8 values 0–9.
Implementations§
Source§impl MnistDataset
impl MnistDataset
Sourcepub fn load(
dir: impl AsRef<Path>,
split: MnistSplit,
) -> Result<Self, MnistError>
pub fn load( dir: impl AsRef<Path>, split: MnistSplit, ) -> Result<Self, MnistError>
Load MNIST from the given directory.
Expects the standard filenames (or .gz compressed versions):
train-images-idx3-ubyte/train-images-idx3-ubyte.gztrain-labels-idx1-ubyte/train-labels-idx1-ubyte.gzt10k-images-idx3-ubyte/t10k-images-idx3-ubyte.gzt10k-labels-idx1-ubyte/t10k-labels-idx1-ubyte.gz
Sourcepub fn from_raw(
image_bytes: &[u8],
label_bytes: &[u8],
split: MnistSplit,
) -> Result<Self, MnistError>
pub fn from_raw( image_bytes: &[u8], label_bytes: &[u8], split: MnistSplit, ) -> Result<Self, MnistError>
Load from raw bytes (useful for embedded/testing).
Sourcepub fn synthetic(n: usize, split: MnistSplit) -> Self
pub fn synthetic(n: usize, split: MnistSplit) -> Self
Create a small synthetic MNIST-like dataset for testing.
Generates n random 28×28 images with random labels.
Sourcepub fn num_samples(&self) -> usize
pub fn num_samples(&self) -> usize
Total number of samples.
Sourcepub fn image_dims(&self) -> (usize, usize)
pub fn image_dims(&self) -> (usize, usize)
Image dimensions: (rows, cols).
Sourcepub fn split(&self) -> MnistSplit
pub fn split(&self) -> MnistSplit
Which split this dataset represents.
Trait Implementations§
Source§impl Dataset for MnistDataset
impl Dataset for MnistDataset
Source§fn feature_shape(&self) -> &[usize]
fn feature_shape(&self) -> &[usize]
The shape of a single feature sample (without batch dim).
Source§fn target_shape(&self) -> &[usize]
fn target_shape(&self) -> &[usize]
The shape of a single target sample (without batch dim).
Auto Trait Implementations§
impl Freeze for MnistDataset
impl RefUnwindSafe for MnistDataset
impl Send for MnistDataset
impl Sync for MnistDataset
impl Unpin for MnistDataset
impl UnsafeUnpin for MnistDataset
impl UnwindSafe for MnistDataset
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more