chaos-moon / paper_daily

One paper a day, keep laziness away.
MIT License
6 stars 3 forks source link

[paper] Constrained Few-shot Class-incremental Learning #11

Open yaoyz96 opened 1 year ago

yaoyz96 commented 1 year ago

C-FSCIL (CVPR 2022)

Constrained Few-shot Class-incremental Learning, CVPR 2022. [paper][code]

Institution & Author

  1. IBM Research-Zurich
  2. ETH Zurich

Motivation

从 supervised classification task 借鉴过来的方法:利用 hyper-dimensional computing 生成 quasi-orthogonal vectors,提高分类任务表现。方法优势:

Contribution

提出 C-FSCIL 框架,用于 Few-shot Incremental Learning 任务:

  1. 利用 hyper-dimensional embedding 进行类别表示,在容纳更大学习空间的同时,减小类间 interference
  2. 三种模型 update mode,在精度和计算资源消耗上提供不同的 trade-off

Preliminaries

FSCIL 任务即 Few-shot Class Incremental Learning,结合了增量学习及小样本学习。FSCIL 顺序提供 $S$ 个训练集 (session) $\mathcal{D}^{(1)}, \mathcal{D}^{(2)}, ..., \mathcal{D}^{(s)}, ..., \mathcal{D}^{(S)}$,其中:

第一个 session $\mathcal{D}^{(1)}$ (s=1) 称作 base session,提供较大的数据集(相对于后续 session 的 few-shot 来说),用于 pre-training 和 meta-training。后续 session $\mathcal{D}^{(s)}$ (s > 1) 的训练样本数量为 $|\mathcal{D}^{(s)}| = c \times k$, $c = |\mathcal{C}^{(s)}|$ 为 class 数量(few-shot ways), $k$ 为每个 class 包含的有标签样本(few-shot shots),c-way k-shot task。

C-FSCIL 模型

模型包含三部分:

C-FSCIL

FE:

FE $f_{\theta_1}$ 将输入数据从 input domain $\mathcal{X}$ 映射到 feature space $\mathbb{R}^{d_f}$:

$$ f_{\theta_1}: \mathcal{X} \rightarrow \mathbb{R}^{d_f} $$

其中, $\theta1$ 为 $f{\theta_1}$ 的可学习参数。

FCL:

(contribution)为了形成 hyper-dimensional distributed representation, $f_{\theta1}$ 与一个 FCL $g{\theta_2}$ 相连,将 feature 从 $\mathbb{R}^{d_f}$ 映射到 $\mathbb{R}^{d}$:

$$ g_{\theta_2}: \mathbb{R}^{d_f} \rightarrow \mathbb{R}^{d}, d < 512 $$

其中, $\theta_2 \in \mathbb{R}^{d \times df}$ 为 $g{\theta_2}$ 的可学习参数。可训练参数 $\theta_1$ 和 $\theta_2$ 联合定义为 embedding network $\theta = (\theta_1, \theta_2)$。

作者提到 $d$ 应该足够大,以确保任意两个随机 $d$ 维向量之间的相似度大概率近似为 0;同时 $d$ 最好小于 $|\widetilde{\mathcal{C}}^{(s)}|$。

EM:

在 session $s$,EM 中存储所有已见类别的 prototype: $P^{(s)}=(p_1, p2, ..., p{|\widetilde{\mathcal{C}}^{(s)}|})$, $P^{(s)} \in \mathbb{R}^{d \times |\widetilde{\mathcal{C}}^{(s)}|}$

相比 few-shot 计算 prototype:直接将 FE 提取的 feature 取平均,C-FSCIL 只是在 FE 之后又加了一个 FCL,做了进一步映射,只不过 mode 1 是先映射再平均,mode 2/3 是先平均再映射。

GAAM(mode 2/3):

(contribution)在 mode 2 和 mode 3 中,FE 的 output feature 在进入 FCL 前,对每个类别所有样本的 feature 求平均,得到每个类别的 globally averaged activations(实际上就是 few-shot 常规做法里的 prototype),存储在 GAAM。但是,这里不将 GAAM 的内容作为类别的 prototype,而是仅用于后续 FCL retrain 阶段的特征对齐。

prototype 的计算:

给出任意一个 query 样本 $x \in \mathcal{E}^{(s)}$ 和 EM 中的 prototype set $\textbf{P}^{(s)} = (p_1, p2, ..., p{|\widetilde{\mathcal{C}}^{(s)}|})$,样本 $x$ 属于类别 $i$ 的得分 $l_i$ 为:

$$ li = \text{cos}(\text{tanh}(g{\theta2}(f{\theta_1}(x))), (\text{tanh}(p_i))) $$

其中, $\text{tanh(·)}$ 为 hyperbolic tangent function(双曲正切函数), $\text{cos(·)}$ 为 cosine similarity(余弦相似度)。最后,score $l_i$ 通过 soft absolute sharpening function $\epsilon(·)$ 进行准正交化 quasi-orthogonality。

相比 few-shot 直接计算 feature 之间的 cosine similarity,C-FSCIL 在 feature 上使用了 $\text{tanh(·)}$ 函数,作者提到这点已经在 MANNs 中证明了, $\text{tanh(·)}$ 能够约束 prototype 及 embedding 的范数

(contribution)对相似度得分使用了 soft absolute sharpening function $\epsilon(·)$ 进行准正交化

3 Update Mode

为了提高 inter-class separation 能力,C-FSCIL 提供了 3 种 update mode,以 memory 和 compute cost 为代价提升 accuracy。

Mode 1: Averaged Prototypes

mode 1 在连续学习阶段(setp 3~x)没有可训练的模块,单纯依靠前两阶段训练好的 FE 和 FCL 对 novel class 进行特征提取。

Mode 2: Retraining on Bipolarized Prototypes

Motivation:随着 new session 增多,类间(inter-class)区分度会逐渐下降,Mode 2 则通过调整 EM 中的 prototype 表示,解决类间区分度下降的问题。

方法:

Mode 3: Retraining on Nudged Prototypes

Motivation:与 Mode 2 的出发点相同,仍然是为了解决类间区分下降的问题。但与 Mode 2 不同的是,Mode 3 基于优化问题提出 prototype alignment 策略,而非简单地对 prototype 加噪声。整个过程和 Mode 2 类似,分为两个阶段:先对 EM 中的 prototype 进行调整,再利用 GAAM 对 FCL 进行 retrain,retrain 结束后 averaged activation 再次通过 FCL,得到最终的 prototypes 保存在 EM 中。

方法:

P.S. Mode 2、3 的预训练阶段(step 1)和 Mode 1 一致,改变的是在 base 和 novel session 上的学习方式,变为 two-stage。

Experiments

Datasets

mini-ImageNet 和 CIFAR100 的数据划分 follow 了工作 Omniglot 的数据划分是本文提出的

Exp. Setup

问题 & 思考

  1. paper里好像没有说如何实现准正交性的?
zc12345 commented 1 year ago

问题:

yaoyz96 commented 1 year ago

问题:

  • EM是他们独创的还是所有incremental learning都有的?看起来像是memory bank/ database之类的东西,分类的时候直接query/retrieval这个database?这个东西是在内存里面的还是dump到本地然后eval的时候再load然后query?
  • 看起来contribution 1单纯是提点的一个操作,1和2之间是并列关系还是递进关系?2的tradeoff和1有关吗?
  • contribution 1让我想起来diffusion中VQ-VAE的codebook操作了,不确定是类似操作还是截然不同,可以参考阅读 https://sunlin-ai.github.io/2022/06/02/VQ-VAE.html
yaoyz96 commented 1 year ago

大概看了 diffusion VQ-VAE,和这里的高维计算差别还是有的。codebook 原理没有细看,但是这里高维计算本质上就是一个 FC,故事包装而已,技术上远没有 codebook 复杂。

yaoyz96 commented 1 year ago

一些改进的思路: