Skip to content

Commit

Permalink
Merge pull request #1019 from AntonioCarta/docs_v2
Browse files Browse the repository at this point in the history
apidoc improvements
  • Loading branch information
AntonioCarta committed May 16, 2022
2 parents bd89058 + 18e83f6 commit b9f4514
Show file tree
Hide file tree
Showing 39 changed files with 584 additions and 272 deletions.
15 changes: 7 additions & 8 deletions avalanche/benchmarks/classic/cinaturalist.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ def SplitInaturalist(
eval_transform: Optional[Any] = _default_eval_transform,
dataset_root: Union[str, Path] = None
):
"""
Creates a CL benchmark using the iNaturalist2018 dataset.
"""Creates a CL benchmark using the iNaturalist2018 dataset.
A selection of supercategories (by default 10) define the experiences.
Note that the supercategories are highly imbalanced in the number of classes
and the amount of data available.
Expand All @@ -66,9 +66,8 @@ def SplitInaturalist(
(120Gtrain/val).
To parse the dataset jsons you need to install an additional dependency:
"pycocotools". You can install it like this:
"conda install -c conda-forge pycocotools"
"pycocotools". You can install it with the command
``conda install -c conda-forge pycocotools``
Implementation is based on the CL survey
(https://ieeexplore.ieee.org/document/9349197) but differs slightly.
Expand Down Expand Up @@ -98,10 +97,10 @@ def SplitInaturalist(
which contains usage examples ranging from "basic" to "advanced".
:param super_categories: The list of supercategories which define the
tasks, i.e. each task consists of all classes in a super-category.
tasks, i.e. each task consists of all classes in a super-category.
:param download: If true and the dataset is not present in the computer,
this method will automatically download and store it. This will take 120G
for the train/val set.
this method will automatically download and store it. This will take
120G for the train/val set.
:param 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.
:param seed: A valid int used to initialize the random number generator.
Expand Down
15 changes: 6 additions & 9 deletions avalanche/benchmarks/classic/clear.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,9 @@
from typing import Union, Any, Optional
from typing_extensions import Literal

from avalanche.benchmarks.classic.classic_benchmarks_utils import (
check_vision_benchmark,
)
from avalanche.benchmarks.datasets.clear import (
CLEARImage,
CLEARFeature,
_CLEARImage,
_CLEARFeature,
SEED_LIST,
CLEAR_FEATURE_TYPES,
)
Expand Down Expand Up @@ -135,15 +132,15 @@ def CLEAR(
raise NotImplementedError()

if feature_type is None:
clear_dataset_train = CLEARImage(
clear_dataset_train = _CLEARImage(
root=dataset_root,
data_name=data_name,
download=True,
split=train_split,
seed=seed,
transform=train_transform,
)
clear_dataset_test = CLEARImage(
clear_dataset_test = _CLEARImage(
root=dataset_root,
data_name=data_name,
download=True,
Expand All @@ -159,15 +156,15 @@ def CLEAR(
)
benchmark_generator = create_generic_benchmark_from_paths
else:
clear_dataset_train = CLEARFeature(
clear_dataset_train = _CLEARFeature(
root=dataset_root,
data_name=data_name,
download=True,
feature_type=feature_type,
split=train_split,
seed=seed,
)
clear_dataset_test = CLEARFeature(
clear_dataset_test = _CLEARFeature(
root=dataset_root,
data_name=data_name,
download=True,
Expand Down
13 changes: 6 additions & 7 deletions avalanche/benchmarks/classic/endless_cl_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,14 @@ def EndlessCLSim(
dataset_root: Union[str, Path] = None,
semseg=False
):
"""
Creates a CL scenario for the Endless-Continual-Learning Simulator's
derived datasets, which are available at:
https://zenodo.org/record/4899267, or custom datasets created from
the Endless-Continual-Learning-Simulator's standalone application,
available at: https://zenodo.org/record/4899294.
"""Creates a CL scenario for the Endless-Continual-Learning Simulator's
derived `datasets <https://zenodo.org/record/4899267>`__, or custom
datasets created from
the Endless-Continual-Learning-Simulator's `standalone application <
https://zenodo.org/record/4899294>`__.
Both are part of the publication of `A Procedural World Generation
Framework for Systematic Evaluation of Continual Learning
(https://arxiv.org/abs/2106.02585).
<https://arxiv.org/abs/2106.02585>`__.
If the dataset is not present in the computer, this method will
automatically download and store it.
Expand Down
1 change: 1 addition & 0 deletions avalanche/benchmarks/datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
from .inaturalist import *
from .lvis_dataset import *
from .penn_fudan import *
from .clear import *
27 changes: 14 additions & 13 deletions avalanche/benchmarks/datasets/clear/clear.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def __len__(self):
return len(self.samples)


class CLEARImage(CLEARDataset):
class _CLEARImage(CLEARDataset):
"""CLEAR Image Dataset (base class for CLEAR10Image)"""

def __init__(
Expand Down Expand Up @@ -222,12 +222,12 @@ def __init__(
aligned with target index.
"""

super(CLEARImage, self).__init__(
super(_CLEARImage, self).__init__(
root, data_name=data_name, download=download, verbose=True
)

def _load_metadata(self) -> bool:
if not super(CLEARImage, self)._load_metadata():
if not super(_CLEARImage, self)._load_metadata():
print("CLEAR has not yet been downloaded")
return False

Expand Down Expand Up @@ -290,7 +290,7 @@ def __len__(self):
return len(self.targets)


class CLEARFeature(CLEARDataset):
class _CLEARFeature(CLEARDataset):
"""CLEAR Feature Dataset (base class for CLEAR10Feature)"""

def __init__(
Expand Down Expand Up @@ -347,12 +347,12 @@ def __init__(
assert feature_type in CLEAR_FEATURE_TYPES[data_name]
self.target_transform = target_transform

super(CLEARFeature, self).__init__(
super(_CLEARFeature, self).__init__(
root, data_name=data_name, download=download, verbose=True
)

def _load_metadata(self) -> bool:
if not super(CLEARFeature, self)._load_metadata():
if not super(_CLEARFeature, self)._load_metadata():
print("CLEAR has not yet been downloaded")
return False

Expand Down Expand Up @@ -433,23 +433,23 @@ def __len__(self):
root = f"../avalanche_datasets/{data_name}"
if not os.path.exists(root):
Path(root).mkdir(parents=True)
clear_dataset_all = CLEARImage(
clear_dataset_all = _CLEARImage(
root=root,
data_name=data_name,
download=True,
split="all",
seed=None,
transform=transform,
)
clear_dataset_train = CLEARImage(
clear_dataset_train = _CLEARImage(
root=root,
data_name=data_name,
download=True,
split="train",
seed=0,
transform=transform,
)
clear_dataset_test = CLEARImage(
clear_dataset_test = _CLEARImage(
root=root,
data_name=data_name,
download=True,
Expand All @@ -461,23 +461,23 @@ def __len__(self):
print("clear10 size (train): ", len(clear_dataset_train))
print("clear10 size (test): ", len(clear_dataset_test))

clear_dataset_all_feature = CLEARFeature(
clear_dataset_all_feature = _CLEARFeature(
root=root,
data_name=data_name,
download=True,
feature_type="moco_b0",
split="all",
seed=None,
)
clear_dataset_train_feature = CLEARFeature(
clear_dataset_train_feature = _CLEARFeature(
root=root,
data_name=data_name,
download=True,
feature_type="moco_b0",
split="train",
seed=0,
)
clear_dataset_test_feature = CLEARFeature(
clear_dataset_test_feature = _CLEARFeature(
root=root,
data_name=data_name,
download=True,
Expand All @@ -499,4 +499,5 @@ def __len__(self):
print(len(y))
break

__all__ = ["CLEARFeature", "CLEARImage", "SEED_LIST", "CLEAR_FEATURE_TYPES"]
__all__ = ["CLEARDataset", "_CLEARFeature", "_CLEARImage", "SEED_LIST",
"CLEAR_FEATURE_TYPES"]
7 changes: 3 additions & 4 deletions avalanche/benchmarks/datasets/core50/core50.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@ def __init__(
object_level=True,
):

"""
Creates an instance of the CORe50 dataset.
"""Creates an instance of the CORe50 dataset.
:param root: root for the datasets data. Defaults to None, which means
that the default location for 'core50' will be used.
:param root: root for the datasets data. Defaults to None, which
means that the default location for 'core50' will be used.
:param train: train or test split.
:param transform: eventual transformations to be applied.
:param target_transform: eventual transformation to be applied to the
Expand Down
6 changes: 2 additions & 4 deletions avalanche/benchmarks/datasets/downloadable_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@


class DownloadableDataset(Dataset[T_co], ABC):
"""
Base class for a downloadable dataset.
"""Base class for a downloadable dataset.
It is recommended to extend this class if a dataset can be downloaded from
the internet. This implementation codes the recommended behaviour for
Expand Down Expand Up @@ -71,8 +70,7 @@ def __init__(
download: bool = True,
verbose: bool = False,
):
"""
Creates an instance of a downloadable dataset.
"""Creates an instance of a downloadable dataset.
Consider looking at the class documentation for the precise details on
how to extend this class.
Expand Down

0 comments on commit b9f4514

Please sign in to comment.