download_prepare_mnist03

Attributes

ROOT

DOWNLOAD_DIR

NPZ_DIR

orig

Functions

load_idx_images(path)

Load MNIST image file (idx3 format) from .gz

load_idx_labels(path)

Load MNIST label file (idx1 format) from .gz

save_to_npz(npz_path, data)

Save the image data and labels with splits "train" and "test" in npz file

save_to_h5(h5_path, data)

Save the image data and labels with splits "train", "val" and "test" in h5 file

main([npz, h5])

Open raw MNIST train and test image data and labels, create val split from train data and save as npz and or h5

Module Contents

download_prepare_mnist03.ROOT
download_prepare_mnist03.DOWNLOAD_DIR
download_prepare_mnist03.NPZ_DIR
download_prepare_mnist03.orig
download_prepare_mnist03.load_idx_images(path: pathlib.Path)

Load MNIST image file (idx3 format) from .gz

Args:

path: path to raw image data gzip file

Returns:

image data as numpy array (n_images, n_rows, n_cols)

download_prepare_mnist03.load_idx_labels(path: pathlib.Path)

Load MNIST label file (idx1 format) from .gz

Args:

path: path to raw label data gzip file

Returns: labels as numpy array (n_labels,)

download_prepare_mnist03.save_to_npz(npz_path, data)

Save the image data and labels with splits “train” and “test” in npz file Args:

npz_path: Path

output path

data: dict

data dict with entries X_train, y_train, X_val, y_val, X_test, y_test

download_prepare_mnist03.save_to_h5(h5_path, data)

Save the image data and labels with splits “train”, “val” and “test” in h5 file Args:

h5_path:

output path

data: dict

data dict with entries X_train, y_train, X_val, y_val, X_test, y_test

download_prepare_mnist03.main(npz=False, h5=True)

Open raw MNIST train and test image data and labels, create val split from train data and save as npz and or h5 Args:

npz: bool

If True, save data and labels as npz file

h5: bool

If True, save data and labels as h5 file