avalanche.benchmarks.classic.PermutedMNIST

avalanche.benchmarks.classic.PermutedMNIST(n_experiences: int, *, return_task_id=False, seed: int | None = None, train_transform: Any | None = Compose(Normalize(mean=(0.1307,), std=(0.3081,))), eval_transform: Any | None = Compose(Normalize(mean=(0.1307,), std=(0.3081,))), dataset_root: str | Path | None = None) NCScenario[source]

Creates a Permuted MNIST benchmark.

If the dataset is not present in the computer, this method will automatically download and store it.

Random pixel permutations are used to permute the MNIST images in n_experiences different manners. This means that each experience is composed of all the original 10 MNIST classes, but the pixel in the images are permuted in a different way.

The benchmark instance returned by this method will have two fields, train_stream and test_stream, which can be iterated to obtain training and test Experience. Each Experience contains the dataset and the associated task label.

A progressive task label, starting from 0, is applied to each experience.

The benchmark API is quite simple and is uniform across all benchmark generators. It is recommended to check the tutorial of the “benchmark” API, which contains usage examples ranging from “basic” to “advanced”.

Parameters:
  • return_task_id – if True, a progressive task id is returned for every experience. If False, all experiences will have a task ID of 0.

  • n_experiences – The number of experiences (tasks) in the current benchmark. It indicates how many different permutations of the MNIST dataset have to be created. The value of this parameter should be a divisor of 10.

  • seed – A valid int used to initialize the random number generator. Can be None.

  • train_transform – The transformation to apply to the training data before the random permutation, e.g. a random crop, a normalization or a concatenation of different transformations (see torchvision.transform documentation for a comprehensive list of possible transformations). If no transformation is passed, the default train transformation will be used.

  • eval_transform – The transformation to apply to the test data before the random permutation, e.g. a random crop, a normalization or a concatenation of different transformations (see torchvision.transform documentation for a comprehensive list of possible transformations). If no transformation is passed, the default test transformation will be used.

  • dataset_root – The root path of the dataset. Defaults to None, which means that the default location for ‘mnist’ will be used.

Returns:

A properly initialized NCScenario instance.