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
- eval_fn#
the function used to evaluate the model on the dataset
- Type:
Callable
- AVAIL_SCHEDS = ['multisteplr', 'cosine']#
- 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>}#
- eval_fn: Callable[[ContinualModel, ContinualDataset, bool, bool], Any]#
- static evaluate(model, dataset, last=False, return_loss=False)[source]#
Evaluates the model on the current task.
- Parameters:
model (ContinualModel) – the model to be evaluated
dataset (ContinualDataset) – the continual dataset at hand (optional). If not provided, the current dataset (self) will be used
last – a boolean indicating whether to evaluate only the last task
return_loss – a boolean indicating whether to return the loss in addition to the accuracy
- Returns:
the evaluation results
- Return type:
- 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:
Tuple[DataLoader, DataLoader]
- static get_denormalization_transform()[source]#
Returns the transform used for denormalizing the current dataset.
- Return type:
Module
- static get_normalization_transform()[source]#
Returns the transform used for normalizing the current dataset.
- Return type:
Module
- 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:
Module
- log(*args, **kwargs)[source]#
Logs the result of the evaluation.
By default, it logs the accuracy of the model on the current task using the utils.loggers.log_accs function.
- 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]#
Bases:
Dataset
,object
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.
- 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:
Tuple[DataLoader, DataLoader]