CONTINUAL DATASET#
Classes#
- class datasets.utils.continual_dataset.ContinualDataset(args)[source]#
Bases:
object
A base class for defining continual learning datasets.
Data is divided into tasks and loaded only when the get_data_loaders method is called.
- class_names#
list of the class names of the dataset (should be populated by get_class_names)
- Type:
List[str]
- train_loader#
the training loader
- Type:
DataLoader
- test_loaders#
the test loaders
- Type:
List[DataLoader]
- args#
the arguments which contains the hyperparameters
- Type:
Namespace
- AVAIL_SCHEDS = ['multisteplr']#
- base_fields = ('SETTING', 'N_CLASSES_PER_TASK', 'N_TASKS', 'SIZE', 'N_CLASSES', 'AVAIL_SCHEDS')#
- composed_fields = {'TEST_TRANSFORM': <function build_torchvision_transform>, 'TRANSFORM': <function build_torchvision_transform>}#
- get_backbone()[source]#
Returns the name of the backbone to be used for the current dataset. This can be changes using the –backbone argument or by setting it in the dataset_config.
- Return type:
- get_data_loaders()[source]#
Creates and returns the training and test loaders for the current task. The current training loader and all test loaders are stored in self.
- Returns:
the current training and test loaders
- Return type:
- static get_denormalization_transform()[source]#
Returns the transform used for denormalizing the current dataset.
- Return type:
- static get_normalization_transform()[source]#
Returns the transform used for normalizing the current dataset.
- Return type:
- get_prompt_templates()[source]#
Returns the prompt templates for the current dataset. By default, it returns the ImageNet prompt templates.
- static get_transform()[source]#
Returns the transform to be used for the current dataset.
- Return type:
- optional_fields = ('MEAN', 'STD')#
- classmethod set_default_from_config(config, parser)[source]#
Sets the default arguments from the configuration file. The default values will be set in the class attributes and will be available for all instances of the class.
The arguments that are related to the dataset (i.e., are in the ‘base_fields’, ‘optional_fields’, or ‘composed_fields’) will be removed from the config dictionary to avoid conflicts with the command line arguments.
- class datasets.utils.continual_dataset.MammothDatasetWrapper(ext_dataset, train=False)[source]#
-
Wraps the datasets used inside the ContinualDataset class to allow for a more flexible retrieval of the data.
- add_extra_return_field(field_name, field_value)[source]#
Adds an extra field to the dataset.
- Parameters:
field_name (str) – the name of the field
field_value – the value of the field
- extend_return_items(ret_tuple, index)[source]#
Extends the return tuple with the extra fields defined in extra_return_fields.
- Parameters:
ret_tuple (Tuple[torch.Tensor, int, torch.Tensor, Optional[torch.Tensor]]) – the current return tuple
- Returns:
the extended return tuple
- Return type:
Tuple[torch.Tensor, int, Optional[torch.Tensor], Sequence[Optional[torch.Tensor]]]
- required_fields = ('data', 'targets')#
Functions#
- datasets.utils.continual_dataset.fix_class_names_order(class_names, args)[source]#
Permutes the order of the class names according to the class order specified in the arguments. The order reflects that of store_masked_loaders.
- datasets.utils.continual_dataset.store_masked_loaders(train_dataset, test_dataset, setting)[source]#
Divides the dataset into tasks.
- datasets.utils.continual_dataset.train_dataset#
the training dataset
- Type:
Dataset
- datasets.utils.continual_dataset.test_dataset#
the test dataset
- Type:
Dataset
- datasets.utils.continual_dataset.setting#
the setting of the dataset
- Type:
- Returns:
the training and test loaders
- Return type: