安装教程 How to Install
网址 pip install avalanche-lib[all]
如果出现ValueError: check_hostname requires server_hostname,请在电脑设置里面关闭服务器代理。
结构 General Architecture
Benchmarks:用于处理数据,使其成为数据流
Training:提供训练模型所需要的工具。这包括实现新的持续学习策略的简单而有效的方法,以及一套预先实现的CL基线和最先进的算法,我们0能够用于比较
Evaluation:提供了所有实用工具和指标,可以帮助评估CL算法的所有因素。
Models:有几个模型架构和预先训练的模型,可以用于持续学习实验
Logging:它包括高级日志和绘图功能,包括本地标准输出,文件和Tensorboard支持(拥有一个完整的交互式仪表板,用一行代码实时跟踪您的实验指标是多么酷啊?)
Avalanche
├── Benchmarks
│ ├── Classic
│ ├── Datasets
│ ├── Generators
│ ├── Scenarios
│ └── Utils
├── Evaluation
│ ├── Metrics
| └── Utils
├── Training
│ ├── Strategies
│ ├── Plugins
| └── Utils
├── Models
└── Loggers
Benchmarks模块提供了三个主要特性:
Datasets:准备使用的PyTorch数据集的全面列表。(可以像使用任何PyTorch数据集一样使用它们。)
from avalanche.benchmarks.datasets import MNIST, FashionMNIST, KMNIST, EMNIST, \
QMNIST, FakeData, CocoCaptions, CocoDetection, LSUN, ImageNet, CIFAR10, \
CIFAR100, STL10, SVHN, PhotoTour, SBU, Flickr8k, Flickr30k, VOCDetection, \
VOCSegmentation, Cityscapes, SBDataset, USPS, HMDB51, UCF101, CelebA, \
CORe50Dataset, TinyImagenet, CUB200, OpenLORIS, MiniImageNetDataset, \
Stream51, CLEARDataset
Classic Benchmarks:一组经典的持续学习基准可供使用(基于单个数据集可以有多个基准)。
阐明几个Benchmarks的基础
- 在Avalanche中,我们通常假设可以访问“train streans”和“test streans”这两个并行的数据流
(即使一些基准测试可能不提供这样的功能,但只包含一个唯一的测试集)。- 每一个streans都是 可迭代、可索引和可切片的对象, 都是由==experiences==组成的。experiences是一批数据(或“task(任务)”),可以提供或不提供特定的任务标签。
from avalanche.benchmarks.classic import CORe50, SplitTinyImageNet, SplitCIFAR10, \
SplitCIFAR100, SplitCIFAR110, SplitMNIST, RotatedMNIST, PermutedMNIST, SplitCUB200
# creating the benchmark (scenario object)
# Permuted MNIST数据集
perm_mnist = PermutedMNIST(
n_experiences=3,# different manners.
# This means that each experience is composed of all the original 10 MNIST classes,
# but the pixel in the images are permuted in a different way
seed=1234,
)
# recovering the train and test streams
# recover 训练流和测试流
train_stream = perm_mnist.train_stream
test_stream = perm_mnist.test_stream
# iterating over the train stream
for experience in train_stream:
print("Start of task ", experience.task_label)
print('Classes in this task(在这份task中有多少classes):', experience.classes_in_this_experience)
# The current Pytorch training set can be easily recovered through the
# experience
# 当前的Pytorch训练集可以很容易地通过experience实现recover
current_training_set = experience.dataset
# ...as well as the task_label
print('Task {}'.format(experience.task_label))
print('This task contains', len(current_training_set), 'training examples')
# we can recover the corresponding test experience in the test stream
current_test_set = test_stream[experience.current_experience].dataset
print('This task contains', len(current_test_set), 'test examples')
Generators:一组函数,可以生成自己的benchmark