Shortcuts

MNISTC

class torch_uncertainty.datasets.classification.MNISTC(root, transform=None, target_transform=None, split='test', subset='all', download=False)[source]

The corrupted MNIST-C Dataset.

Parameters:
  • root (str) – Root directory of the datasets.

  • transform (callable, optional) – A function/transform that takes in a PIL image and returns a transformed version. E.g, transforms.RandomCrop. Defaults to None.

  • target_transform (callable, optional) – A function/transform that takes in the target and transforms it. Defaults to None.

  • subset (str) – The subset to use, one of all or the keys in mnistc_subsets.

  • download (bool, optional) – If True, downloads the dataset from the internet and puts it in root directory. If dataset is already downloaded, it is not downloaded again. Defaults to False.

References

Mu, Norman, and Justin Gilmer. “MNIST-C: A robustness benchmark for computer vision.” In ICMLW 2019.

License:

The dataset is released by the dataset’s authors under the Creative Commons Attribution 4.0.

Note

This dataset does not contain severity levels. Raise an issue if you want someone to investigate this.

download()[source]

Download the dataset.

make_dataset(root, subset, split)[source]
Build the corrupted dataset according to the chosen subset and

severity. If the subset is ‘all’, gather all corruption types in the dataset.

Parameters:
  • root (Path) – The path to the dataset.

  • subset (str) – The name of the corruption subset to be used. Choose all for the dataset to contain all subsets.

  • split (str) – The split to be used, either train or test.

Returns:

The samples and labels of the chosen.

Return type:

Tuple[np.ndarray, np.ndarray]