Crate cifar_ten

Crate cifar_ten 

Source
Expand description

This library parses the binary files of the CIFAR-10 data set and returns them as a tuple struct

  • CifarResult: (Vec<u8>, Vec<u8>, Vec<u8>, Vec<u8>) which is organized as (train_data, train_labels, test_data, test_labels)

Convenience methods for converting these to the Rust ndarray numeric arrays are provided using the to_ndarray feature flag, as well as for automatically downloading binary training data from a remote url.

// $ cargo build --features=download,to_ndarray
use cifar_ten::*;

fn main() {
    let (train_data, train_labels, test_data, test_labels) = Cifar10::default()
        .download_and_extract(true)
        .encode_one_hot(true)
        .build()
        .unwrap()
        .to_ndarray::<f32>()
        .expect("Failed to build CIFAR-10 data");
}

A tar.gz file with the original binaries can be found here. The crate’s author also provides several ML data mirrors here which are used for running tests on this library. Please feel free to use, but should you expect to make heavy use of these files, please consider creating your own mirror.

If you’d like to verify that the correct images and labels are being provided, the examples/preview_images.rs file using show-image to preview a RGB representation of a given image with the corresponding one-hot formatted label.

Structs§

Cifar10
Data structure used to specify where/how the CIFAR-10 binary data is parsed
CifarResult
Primary data return, wrapper around tuple (Vec<u8>, Vec<u8>, Vec<u8>, Vec<u8>)