【Avalanche教程】

Avalanche是一个全面的持续学习框架,包括Benchmarks、Training、Evaluation和Logging模块。Benchmarks提供预处理的PyTorch数据集和经典基准,如MNIST和CIFAR10。用户可以通过创建数据流和体验来处理训练和测试。Training模块支持多种持续学习策略和插件。Evaluation模块则包含评估指标。文章还介绍了如何安装Avalanche及其基本用法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

安装教程 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

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一位不愿透漏姓氏的许先森

你的鼓励是我最大的动力!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值