Shortcuts

MNISTDataModule

class torch_uncertainty.datamodules.MNISTDataModule(root, batch_size, eval_ood=False, ood_ds='fashion', val_split=None, num_workers=1, cutout=None, test_alt=None, pin_memory=True, persistent_workers=True)[source]

DataModule for MNIST.

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

  • eval_ood (bool) – Whether to evaluate on out-of-distribution data.

  • batch_size (int) – Number of samples per batch.

  • ood_ds (str) – Which out-of-distribution dataset to use. Defaults to "fashion"; fashion stands for FashionMNIST and not for notMNIST.

  • val_split (float) – Share of samples to use for validation. Defaults to 0.0.

  • num_workers (int) – Number of workers to use for data loading. Defaults to 1.

  • cutout (int) – Size of cutout to apply to images. Defaults to None.

  • test_alt (str) – Which test set to use. Defaults to None.

  • pin_memory (bool) – Whether to pin memory. Defaults to True.

  • persistent_workers (bool) – Whether to use persistent workers. Defaults to True.

  • kwargs – Additional arguments.

prepare_data()[source]

Download the datasets.

test_dataloader()[source]

Get the test dataloaders for MNIST.

Returns:

Dataloaders of the MNIST test set (in

distribution data) and FashionMNIST test split (out-of-distribution data).

Return type:

List[DataLoader]