mnist_reader 0.1.1

Download the MNIST dataset and simply read it.
Documentation
  • Coverage
  • 57.14%
    8 out of 14 items documented1 out of 8 items with examples
  • Size
  • Source code size: 21.54 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 441.03 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 27s Average build duration of successful builds.
  • all releases: 26s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • kujirahand/mnist_reader-rust
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • kujirahand

MNIST Reader for Rust

This crate provides a reader for the MNIST dataset.

It downloads the dataset from GitHub if it is not already present in the specified directory. It also provides methods to load the data into memory.

You can easily download and use the MNIST data as shown below.

use crate::mnist_reader::{MnistReader, print_image};

fn main() {
    // read MNIST data
    let mut mnist = MnistReader::new("mnist-data");
    // download MNIST data
    mnist.load().unwrap();
    println!("Train data size: {}", mnist.train_data.len());
    println!("Test data size: {}", mnist.test_data.len());
    println!("Train labels size: {}", mnist.train_labels.len());
    println!("Test labels size: {}", mnist.test_labels.len());
    // print the first image
    let train_data: Vec<Vec<f32>> = mnist.train_data;
    println!("images[0]={:?}", train_data[0]);
    print_image(&train_data[0]);
    // print the first label
    let train_labels: Vec<u8> = mnist.train_labels;
    println!("labels[0]={:?}", train_labels[0]);
}

Download the MNIST dataset

This crate downloads the original MNIST dataset from GitHub.

The original MNIST dataset was hosted at http://yann.lecun.com/exdb/mnist/, but it is no longer available. Therefore, this crate downloads the Gzip files from a GitHub mirror.

Link