dataset_mnist03_h5
Classes
Dataset class for MNIST03 (MNIST numbers 0-3) stored in HDF5 format. |
Module Contents
- class dataset_mnist03_h5.Mnist03Dataset(h5_path, split='train', normalize=True, flatten=True)
Dataset class for MNIST03 (MNIST numbers 0-3) stored in HDF5 format. Split in train, val and test set, image data and corresponding labels for each split are accessible through
/<split>/images : uint8 [N, 28, 28] /<split>/labels : int64 [N]
- Args:
h5_path: Path to HDF5 file split: Dataset split (“train”, “val” or “test”). Default is “train”. normalize: bool
If True, normalize the images to [0, 1]. Default is True.
- flatten: bool
If True, flatten the images from (1, 28, 28) to (784,). Default is True.
- h5_path = ''
- split = 'train'
- normalize = True
- flatten = True
- _file = None
- _pid = None
- _length = None
- _ensure_open()
Open the HDF5 file
- Returns: h5py.File
A handle to the open HDF5 file (read-only)
- __len__()
Number of samples in the current split.
- __getitem__(idx)
Get a sample from the data set Args:
idx: index of sample
- Returns:
- X_t: torch.Tensor
sample image tensor
- y_t: torch.Tensor
sample label tensor
- __del__()
Close the HDF5 file