Struct mnist::MnistBuilder [−][src]
pub struct MnistBuilder<'a> { /* fields omitted */ }
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
Set the labels format to scalar.
Examples
let mnist = MnistBuilder::new()
.label_format_digit()
.finalize();
Set the labels format to vector.
Examples
let mnist = MnistBuilder::new()
.label_format_one_hot()
.finalize();
Set the training set length.
Examples
let mnist = MnistBuilder::new()
.training_set_length(40_000)
.finalize();
Set the validation set length.
Examples
let mnist = MnistBuilder::new()
.validation_set_length(10_000)
.finalize();
Set the test set length.
Examples
let mnist = MnistBuilder::new()
.test_set_length(10_000)
.finalize();
Set the base path to look for the MNIST data files.
Examples
let mnist = MnistBuilder::new()
.base_path("data_sets/mnist")
.finalize();
pub 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();
pub 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();
Set the test images data set filename.
Examples
let mnist = MnistBuilder::new()
.test_images_filename("test_images")
.finalize();
Set the test labels data set filename.
Examples
let mnist = MnistBuilder::new()
.test_labels_filename("test_labels")
.finalize();
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();
Uses the Fashion MNIST dataset rather than the original
Examples
let mnist = MnistBuilder::new()
.use_fashion_data()
.finalize();
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();