Struct mnist::MnistBuilder
source · pub struct MnistBuilder<'a> { /* private fields */ }
Expand description
Struct used for configuring how to load the MNIST data.
- lbl_format - Specify how to format the label vectors. Options include:
- Digit (default) - a single number from 0-9 representing the corresponding digit.
- OneHotVector - a 1x10 one-hot vector of all 0’s except for a 1 at the index of the digit.
- ex.)
3 -> [0, 0, 0, 1, 0, 0, 0, 0, 0, 0]
- ex.)
- trn_len - the length of the training set
(default = 60,000)
- val_len - the length of the validation set
(default = 0)
- tst_len - the length of the test set
(default = 10,000)
- base_path - the path to the directory in which to look for the MNIST data files.
(default = "data/")
- trn_img_filename - the filename of the training images data file.
(default = "train-images-idx3-ubyte")
- trn_lbl_filename - the filename of the training labels data file.
(default = "train-labels-idx1-ubyte")
- tst_img_filename - the filename of the test images data file.
(default = "10k-images-idx3-ubyte")
- tst_lbl_filename - the filename of the test labels data file.
(default = "t10k-labels-idx1-ubyte")
Implementations§
source§impl<'a> MnistBuilder<'a>
impl<'a> MnistBuilder<'a>
sourcepub fn new() -> MnistBuilder<'a>
pub fn new() -> MnistBuilder<'a>
sourcepub fn label_format_digit(&mut self) -> &mut MnistBuilder<'a>
pub fn label_format_digit(&mut self) -> &mut MnistBuilder<'a>
Set the labels format to scalar.
Examples
let mnist = MnistBuilder::new()
.label_format_digit()
.finalize();
sourcepub fn label_format_one_hot(&mut self) -> &mut MnistBuilder<'a>
pub fn label_format_one_hot(&mut self) -> &mut MnistBuilder<'a>
Set the labels format to vector.
Examples
let mnist = MnistBuilder::new()
.label_format_one_hot()
.finalize();
sourcepub fn training_set_length(&mut self, length: u32) -> &mut MnistBuilder<'a>
pub fn training_set_length(&mut self, length: u32) -> &mut MnistBuilder<'a>
Set the training set length.
Examples
let mnist = MnistBuilder::new()
.training_set_length(40_000)
.finalize();
sourcepub fn validation_set_length(&mut self, length: u32) -> &mut MnistBuilder<'a>
pub fn validation_set_length(&mut self, length: u32) -> &mut MnistBuilder<'a>
Set the validation set length.
Examples
let mnist = MnistBuilder::new()
.validation_set_length(10_000)
.finalize();
sourcepub fn test_set_length(&mut self, length: u32) -> &mut MnistBuilder<'a>
pub fn test_set_length(&mut self, length: u32) -> &mut MnistBuilder<'a>
Set the test set length.
Examples
let mnist = MnistBuilder::new()
.test_set_length(10_000)
.finalize();
sourcepub fn base_path(&mut self, base_path: &'a str) -> &mut MnistBuilder<'a>
pub fn base_path(&mut self, base_path: &'a str) -> &mut MnistBuilder<'a>
Set the base path to look for the MNIST data files.
Examples
let mnist = MnistBuilder::new()
.base_path("data_sets/mnist")
.finalize();
sourcepub fn training_images_filename(
&mut self,
trn_img_filename: &'a str
) -> &mut MnistBuilder<'a>
pub fn training_images_filename( &mut self, trn_img_filename: &'a str ) -> &mut MnistBuilder<'a>
Set the training images data set filename.
Examples
let mnist = MnistBuilder::new()
.training_images_filename("training_images")
.finalize();
sourcepub fn training_labels_filename(
&mut self,
trn_lbl_filename: &'a str
) -> &mut MnistBuilder<'a>
pub fn training_labels_filename( &mut self, trn_lbl_filename: &'a str ) -> &mut MnistBuilder<'a>
Set the training labels data set filename.
Examples
let mnist = MnistBuilder::new()
.training_labels_filename("training_labels")
.finalize();
sourcepub fn test_images_filename(
&mut self,
tst_img_filename: &'a str
) -> &mut MnistBuilder<'a>
pub fn test_images_filename( &mut self, tst_img_filename: &'a str ) -> &mut MnistBuilder<'a>
Set the test images data set filename.
Examples
let mnist = MnistBuilder::new()
.test_images_filename("test_images")
.finalize();
sourcepub fn test_labels_filename(
&mut self,
tst_lbl_filename: &'a str
) -> &mut MnistBuilder<'a>
pub fn test_labels_filename( &mut self, tst_lbl_filename: &'a str ) -> &mut MnistBuilder<'a>
Set the test labels data set filename.
Examples
let mnist = MnistBuilder::new()
.test_labels_filename("test_labels")
.finalize();
sourcepub fn download_and_extract(&mut self) -> &mut MnistBuilder<'a>
pub fn download_and_extract(&mut self) -> &mut MnistBuilder<'a>
Download and extract MNIST dataset if not present.
If archives are already present, they will not be downloaded.
If datasets are already present, they will not be extracted.
Note that this requires the ‘download’ feature to be enabled (disabled by default).
Examples
let mnist = MnistBuilder::new()
.download_and_extract()
.finalize();
sourcepub fn use_fashion_data(&mut self) -> &mut MnistBuilder<'a>
pub fn use_fashion_data(&mut self) -> &mut MnistBuilder<'a>
Uses the Fashion MNIST dataset rather than the original
Examples
let mnist = MnistBuilder::new()
.use_fashion_data()
.finalize();
sourcepub fn base_url(&mut self, base_url: &'a str) -> &mut MnistBuilder<'a>
pub fn base_url(&mut self, base_url: &'a str) -> &mut MnistBuilder<'a>
Download the .gz files from the specified url rather than the standard one
Examples
let mnist = MnistBuilder::new()
.base_url("<desired_url_here>")
.download_and_extract()
.finalize();