avalanche.benchmarks.classic.SplitMNIST

avalanche.benchmarks.classic.SplitMNIST(n_experiences: int, *, return_task_id=False, seed: typing.Optional[int] = None, fixed_class_order: typing.Optional[typing.Sequence[int]] = None, shuffle: bool = True, train_transform: typing.Optional[typing.Any] = Compose(     ToTensor()     Normalize(mean=(0.1307, ), std=(0.3081, )) ), eval_transform: typing.Optional[typing.Any] = Compose(     ToTensor()     Normalize(mean=(0.1307, ), std=(0.3081, )) ), dataset_root: typing.Optional[typing.Union[str, pathlib.Path]] = None)[source]

Creates a CL benchmark using the MNIST dataset.

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

The returned benchmark will return experiences containing all patterns of a subset of classes, which means that each class is only seen “once”. This is one of the most common scenarios in the Continual Learning literature. Common names used in literature to describe this kind of scenario are “Class Incremental”, “New Classes”, etc. By default, an equal amount of classes will be assigned to each experience.

This generator doesn’t force a choice on the availability of task labels, a choice that is left to the user (see the return_task_id parameter for more info on task labels).

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.

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
  • n_experiences – The number of incremental experiences in the current benchmark. The value of this parameter should be a divisor of 10.

  • 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.

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

  • fixed_class_order – A list of class IDs used to define the class order. If None, value of seed will be used to define the class order. If non-None, seed parameter will be ignored. Defaults to None.

  • shuffle – If true, the class order in the incremental experiences is randomly shuffled. Default to false.

  • train_transform – The transformation to apply to the training data, 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, 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.