diff --git a/README.md b/README.md index c6e963ee4..ea8809f5f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -
+div align="center"> # Avalanche: an End-to-End Library for Continual Learning **[Avalanche Website](https://avalanche.continualai.org)** | **[Getting Started](https://avalanche.continualai.org/getting-started)** | **[Examples](https://avalanche.continualai.org/examples)** | **[Tutorial](https://avalanche.continualai.org/from-zero-to-hero-tutorial)** | **[API Doc](https://avalanche-api.continualai.org)** | **[Paper](https://arxiv.org/abs/2104.00405)** | **[Twitter](https://twitter.com/AvalancheLib)** diff --git a/avalanche/benchmarks/scenarios/__init__.py b/avalanche/benchmarks/scenarios/__init__.py index 83db82055..a3ecad792 100644 --- a/avalanche/benchmarks/scenarios/__init__.py +++ b/avalanche/benchmarks/scenarios/__init__.py @@ -8,4 +8,5 @@ from .dataset_scenario import * from .exmodel_scenario import * from .online import * +from .supervised import * from .validation_scenario import * diff --git a/avalanche/benchmarks/scenarios/dataset_scenario.py b/avalanche/benchmarks/scenarios/dataset_scenario.py index cf5f7afa3..d00f2ac04 100644 --- a/avalanche/benchmarks/scenarios/dataset_scenario.py +++ b/avalanche/benchmarks/scenarios/dataset_scenario.py @@ -28,7 +28,7 @@ Dict, ) -from .generic_scenario import EagerCLStream, CLScenario, CLExperience, make_stream +from .generic_scenario import EagerCLStream, CLScenario, CLExperience from ..utils import TaskAwareSupervisedClassificationDataset @@ -257,4 +257,5 @@ def __iter__( "benchmark_from_datasets", "DatasetExperience", "split_validation_random", + "split_validation_class_balanced", ] diff --git a/avalanche/benchmarks/scenarios/supervised.py b/avalanche/benchmarks/scenarios/supervised.py index 8e46446db..c9a5f36ce 100644 --- a/avalanche/benchmarks/scenarios/supervised.py +++ b/avalanche/benchmarks/scenarios/supervised.py @@ -417,3 +417,10 @@ def _decorate_stream(obj: CLStream): raise ValueError( "Unsupported object type: must be one of {CLScenario, CLStream}" ) + + +__all__ = [ + "class_incremental_benchmark", + "new_instances_benchmark", + "with_classes_timeline", +] diff --git a/avalanche/benchmarks/scenarios/validation_scenario.py b/avalanche/benchmarks/scenarios/validation_scenario.py index b3cb08eb3..74d3bb2ad 100644 --- a/avalanche/benchmarks/scenarios/validation_scenario.py +++ b/avalanche/benchmarks/scenarios/validation_scenario.py @@ -1,20 +1,13 @@ from typing import ( Callable, - Generator, - Generic, - List, - Sequence, - TypeVar, Union, Tuple, Optional, - Iterable, - Dict, ) import random from avalanche.benchmarks.utils.data import AvalancheDataset -from .generic_scenario import EagerCLStream, CLScenario, CLExperience, make_stream +from .generic_scenario import EagerCLStream, CLScenario, make_stream from .dataset_scenario import ( LazyTrainValSplitter, DatasetExperience, diff --git a/docs/benchmarks.rst b/docs/benchmarks.rst index d87d22cc1..922214387 100644 --- a/docs/benchmarks.rst +++ b/docs/benchmarks.rst @@ -20,7 +20,7 @@ avalanche.benchmarks .. currentmodule:: avalanche.benchmarks.scenarios Continual Learning Scenarios -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +---------------------------------------- | Generic definitions for scenarios, streams and experiences. All the continual learning benchmarks are specific instantiations of these concepts. @@ -50,7 +50,7 @@ Streams ClassificationStream Experiences -""""""""" +""""""""""""" .. autosummary:: :toctree: generated @@ -210,7 +210,7 @@ Benchmarks for learning from pretrained models or multi-agent continual learning .. currentmodule:: avalanche.benchmarks.datasets Datasets -^^^^^^^^^^^^^^^^^^^^^^^^^^ +---------------------------------------- | The **datasets** sub-module provides PyTorch dataset implementations for datasets missing from the torchvision/audio/* libraries. These datasets can also be used in a standalone way! @@ -236,52 +236,54 @@ Datasets torchaudio_wrapper.SpeechCommands -.. currentmodule:: avalanche.benchmarks.scenarios.deprecated.generators +.. currentmodule:: avalanche.benchmarks Benchmark Generators -^^^^^^^^^^^^^^^^^^^^^^^^^^ -| The **generators** sub-module provides a lot of functions that can be used to create a new benchmark. -| This set of functions tries to cover most common use cases (Class/Task-Incremental, Domain-Incremental, ...) but it also allows for the creation of entirely custom benchmarks (based on lists of tensors, on file lists, ...). - +---------------------------------------- -Generators for Class/Task/Domain-incremental benchmarks -........................................................ +| The **generators** sub-module provides a lot of functions that can be used to create a new benchmark. +| This set of functions tries to cover most common use cases (Class/Task-Incremental, Domain-Incremental, ...) but it also allows for the creation of entirely custom benchmarks from AvalancheDatasets. .. autosummary:: :toctree: generated - nc_benchmark - ni_benchmark - + benchmark_from_datasets + class_incremental_benchmark + new_instances_benchmark + task_incremental_benchmark -Starting from tensor lists, file lists, PyTorch datasets -.......................................................... +If you want to add attributes to experiences (such as `classes_in_this_experiences` or `task_labels`) you can use the generic decorators: .. autosummary:: :toctree: generated - dataset_benchmark - filelist_benchmark - paths_benchmark - tensors_benchmark + with_classes_timeline + with_task_labels +Online streams where experiences are made of small minibatches: + +.. autosummary:: + :toctree: generated -Misc (make data-incremental, add a validation stream, ...) -.............................................................. + split_online_stream + split_continuous_linear_decay_stream -| Avalanche offers utilities to adapt a previously instantiated benchmark object. -| More utilities to come! +Train/Validation splits for streams: .. autosummary:: :toctree: generated - data_incremental_benchmark + benchmark_with_validation_stream + split_validation_class_balanced + split_validation_random + .. currentmodule:: avalanche.benchmarks.utils Utils (Data Loading and AvalancheDataset) -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +-------------------------------------------------------------------------------- + | The custom dataset and dataloader implementations contained in this sub-module are described in more detailed in the How-Tos about `"data loading and replay" ` and `"Avalanche Dataset" `. diff --git a/docs/gitbook/from-zero-to-hero-tutorial/03_benchmarks.md b/docs/gitbook/from-zero-to-hero-tutorial/03_benchmarks.md index fd0e674d0..0d9c83ee9 100644 --- a/docs/gitbook/from-zero-to-hero-tutorial/03_benchmarks.md +++ b/docs/gitbook/from-zero-to-hero-tutorial/03_benchmarks.md @@ -186,10 +186,9 @@ print(f"{bm.test_stream.name} - len {len(bm.test_stream)}") we can also split a validation stream from the training stream - ```python -from avalanche.benchmarks.scenarios.dataset_scenario import benchmark_with_validation_stream +from avalanche.benchmarks.scenarios.validation_scenario import benchmark_with_validation_stream print(f"original training samples = {len(bm.train_stream[0].dataset)}") diff --git a/docs/models.rst b/docs/models.rst index 0b2ab30eb..a80abe459 100644 --- a/docs/models.rst +++ b/docs/models.rst @@ -14,7 +14,7 @@ models .. currentmodule:: avalanche.models Dynamic Modules -^^^^^^^^^^^^^^^ +------------------ Dynamic Modules are Pytorch modules that can be incrementally expanded to allow architectural modifications (multi-head classifiers, progressive @@ -28,9 +28,22 @@ networks, ...). IncrementalClassifier MultiHeadClassifier +Progressive Neural Networks +^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Modules that implement progressive neural networks models, layers, and adapters. + +.. autosummary:: + :toctree: generated + + PNN + PNNLayer + PNNColumn + LinearAdapter + MLPAdapter + Models -^^^^^^^^^^^^^^^^^^^^^^^ +------------------ | Neural network architectures that can be used as backbones for CL experiments. @@ -57,22 +70,8 @@ Models ExpertGate -Progressive Neural Networks -^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Modules that implement progressive neural networks models, layers, and adapters. - -.. autosummary:: - :toctree: generated - - PNN - PNNLayer - PNNColumn - LinearAdapter - MLPAdapter - - Model Wrappers and Utilities -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +------------------------------------ Wrappers and functions that add utility support to your models. .. autosummary:: @@ -87,7 +86,7 @@ Wrappers and functions that add utility support to your models. pytorchcv_wrapper.get_model Dynamic optimizer utilities -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +------------------------------------ Utilities to handle optimizer's update when using dynamic architectures. Dynamic Modules (e.g. multi-head) can change their parameters dynamically