avalanche.benchmarks.generators.tensors_benchmark

avalanche.benchmarks.generators.tensors_benchmark(train_tensors: Sequence[Sequence[Any]], test_tensors: Sequence[Sequence[Any]], *, other_streams_tensors: Optional[Dict[str, Sequence[Sequence[Any]]]] = None, task_labels: Sequence[int], complete_test_set_only: bool = False, train_transform=None, train_target_transform=None, eval_transform=None, eval_target_transform=None, other_streams_transforms: Optional[Dict[str, Tuple[Any, Any]]] = None, dataset_type: Optional[avalanche.benchmarks.utils.avalanche_dataset.AvalancheDatasetType] = None) avalanche.benchmarks.scenarios.classification_scenario.GenericCLScenario

Creates a benchmark instance given lists of Tensors. A separate dataset will be created from each Tensor tuple (x, y, z, …) and each of those training datasets will be considered a separate training experience. Using this helper function is the lowest-level way to create a Continual Learning benchmark. When possible, consider using higher level helpers.

Experiences are defined by passing lists of tensors as the train_tensors, test_tensors (and other_streams_tensors) parameters. Those parameters must be lists containing lists of tensors, one list for each experience. Each tensor defines the value of a feature (“x”, “y”, “z”, …) for all patterns of that experience.

By default the second tensor of each experience will be used to fill the targets value (label of each pattern).

Beware that task labels can only be defined by choosing a single task label for each experience (the same task label is applied to all patterns of experiences sharing the same position in different streams).

When in need to create a benchmark instance in which task labels are defined in a more fine-grained way, then consider using create_multi_dataset_generic_benchmark() by passing properly initialized AvalancheDataset instances.

Parameters
  • train_tensors – A list of lists. The first list must contain the tensors for the first training experience (one tensor per feature), the second list must contain the tensors for the second training experience, and so on.

  • test_tensors – A list of lists. The first list must contain the tensors for the first test experience (one tensor per feature), the second list must contain the tensors for the second test experience, and so on. When using complete_test_set_only, this parameter must be a list containing a single sub-list for the single test experience.

  • other_streams_tensors – A dictionary describing the content of custom streams. Keys must be valid stream names (letters and numbers, not starting with a number) while the value follow the same structure of train_tensors and test_tensors parameters. If this dictionary contains the definition for “train” or “test” streams then those definition will override the train_tensors and test_tensors parameters.

  • task_labels – A list of task labels. Must contain at least a value for each experience. Each value describes the task label that will be applied to all patterns of a certain experience. For more info on that, see the function description.

  • complete_test_set_only – If True, only the complete test set will be returned by the benchmark. This means that test_tensors must define a single experience. Defaults 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). Defaults to None.

  • train_target_transform – The transformation to apply to training patterns targets. Defaults to None.

  • 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). Defaults to None.

  • eval_target_transform – The transformation to apply to test patterns targets. Defaults to None.

  • other_streams_transforms – Transformations to apply to custom streams. If no transformations are defined for a custom stream, then “train” transformations will be used. This parameter must be a dictionary mapping stream names to transformations. The transformations must be a two elements tuple where the first element defines the X transformation while the second element is the Y transformation. Those elements can be None. If this dictionary contains the transformations for “train” or “test” streams then those transformations will override the train_transform, train_target_transform, eval_transform and eval_target_transform parameters.

  • dataset_type – The type of the dataset. Defaults to UNDEFINED.

Returns

A GenericCLScenario instance.