在本文中,我们提出了一种新的基于传输的方法,旨在处理特征向量,使其更接近高斯分布,从而提高了精度。
对于在训练期间可以使用未标记测试样本的转导小样本学习,我们还引入了一种优化传输启发算法,以进一步提高所达到的性能。使用标准化的视觉基准,我们展示了所提出的方法能够通过各种数据集、主干架构和少镜头设置实现最先进的精度。
文章目录
Feature extraction
第一步是仅使用基础数据集训练神经网络主干模型。 在这项工作中,我们考虑了多个主干,以及各种训练程序。 一旦所考虑的主干被训练,我们就会获得强大的嵌入,这些嵌入应该很好地推广到新的类。
特征提取网络记作 f φ f_{\varphi} fφ,通过骨干提取网络的倒数第二层的输出得到。对于输入 x x x, f φ ( x ) f_{\varphi}(x) fφ(x)是一个维度为 d d d的向量,可以被认为是 x x x的一种更容易操作的表示
在使用的所有骨干架构中,倒数第二层都是通过应用ReLU函数获得的,因此所有从 f φ f_{\varphi} fφ中出来的特征数值都是非负的
Feature preprocessing
-
Euclidean normalization
该步长将特征缩放到相同的区域,这样方差较大的特征向量不会占其他特征向量的优势。
f φ ( x ) ← f φ ( x ) ∥ f φ ( x ) ∥ 2 f_{\varphi}(\mathbf{x}) \leftarrow \frac{f_{\varphi}(\mathbf{x})}{\left\|f_{\varphi}(\mathbf{x})\right\|_{2}} fφ(x)←∥fφ(x)∥2fφ(x) -
Power transform
基本原理是幂变换,通常与欧几里得归一化结合使用,具有减少分布偏斜并将其映射到接近高斯分布的功能,由 β \beta β调整
f φ h ( x ) ← ( f φ h ( x ) + ϵ ) β , β ≠ 0 f_{\varphi}^{h}(\mathbf{x}) \leftarrow\left(f_{\varphi}^{h}(\mathbf{x})+\epsilon\right)^{\beta}, \quad \beta \neq 0 fφh(x)←(fφh(x)+ϵ)β,β=0
ϵ = 1 e − 6 \epsilon=1e-6 ϵ=1e−6, β \beta β是超参数 -
Mean subtraction
使用均值减法,每个样本使用 m ∈ ( R + ) d \mathbf{m} \in\left(\mathbb{R}^{+}\right)^{d} m∈(R+)d投影中心进行平移。这通常与欧几里德归一化结合使用,以减少任务偏差和更好地对齐特征分布
f φ ( x ) ← f φ ( x ) − m f_{\varphi}(\mathbf{x}) \leftarrow f_{\varphi}(\mathbf{x})-\mathbf{m} fφ(x)←fφ(x)−m
Boosted Min-size Sinkhorn
首先,我们定义一个权重矩阵
W
W
W,它有
n
n
n列(即每个类一列)和
d
d
d行(即每个特征向量维度一行),对于
W
W
W 中的列
j
j
j,我们将其表示为类
j
j
j的权重参数
w
j
∈
R
d
\mathbf{w}_{j} \in \mathbb{R}^{d}
wj∈Rd,通过下面方程式计算:
w
j
=
W
[
:
,
j
]
=
c
j
/
∥
c
j
∥
2
,
c
j
=
1
s
∑
x
∈
S
,
ℓ
(
x
)
=
j
f
φ
(
x
)
.
\begin{gathered} \mathbf{w}_{j}=\mathbf{W}[:, j]=\mathbf{c}_{j} /\left\|\mathbf{c}_{j}\right\|_{2}, \\ \mathbf{c}_{j}=\frac{1}{s} \sum_{\mathbf{x} \in \mathbf{S}, \ell(\mathbf{x})=j} f_{\varphi}(\mathbf{x}) . \end{gathered}
wj=W[:,j]=cj/∥cj∥2,cj=s1x∈S,ℓ(x)=j∑fφ(x).
我们可以看到,
W
W
W包含了每个类支持集中特征向量的平均值,然后对每个列进行
L
2
L_2
L2归一化处理,使
∀
j
,
∥
w
j
∥
2
=
1
\forall j , \left\|\mathbf{w}_{j}\right\|_{2}=1
∀j,∥wj∥2=1.
然后,我们迭代后面描述的多个步骤
a. Computing costs
将样本
i
i
i 和类别
j
j
j 之间的成本定义为以下对应于余弦距离的等式:
C
[
i
,
j
]
∝
(
f
φ
(
x
i
)
−
w
j
)
2
=
1
−
w
j
T
f
φ
(
x
i
)
\begin{aligned} \mathbf{C}[i, j] & \propto\left(f_{\varphi}\left(\mathbf{x}_{i}\right)-\mathbf{w}_{j}\right)^{2} \\ &=1-\mathbf{w}_{j}^{T} f_{\varphi}\left(\mathbf{x}_{i}\right) \end{aligned}
C[i,j]∝(fφ(xi)−wj)2=1−wjTfφ(xi)
对应源代码的score
b. Min-size Sinkhorn
P = Sinkhorn ( C , p , q , λ ) = argmin P ~ ∈ U ( p , q ) ∑ i j P ~ [ i , j ] C [ i , j ] + λ H ( P ~ ) \begin{aligned} \mathbf{P} &=\operatorname{Sinkhorn}(\mathbf{C}, \mathbf{p}, \mathbf{q}, \lambda) \\ &=\underset{\tilde{\mathbf{P}} \in \mathbb{U}(\mathbf{p}, \mathbf{q})}{\operatorname{argmin}} \sum_{i j} \tilde{\mathbf{P}}[i, j] \mathbf{C}[i, j]+\lambda H(\tilde{\mathbf{P}}) \end{aligned} P=Sinkhorn(C,p,q,λ)=P~∈U(p,q)argminij∑P~[i,j]C[i,j]+λH(P~)
其中行总和为 p,列总和为 q,p 表示每个样本用于类别分配的数量的分布,q 表示分配给每个类别的样本数量的分布。
因此,U(p;q) 包含所有可能的分配方式。 在同一个等式中,C 可以看作是一个成本矩阵
P ~ \tilde{\mathbf{P}} P~的交叉熵 : H ( P ~ ) = − ∑ i j P ~ [ i , j ] log P ~ [ i , j ] : H(\tilde{\mathbf{P}})=-\sum_{i j} \tilde{\mathbf{P}}[i, j] \log \tilde{\mathbf{P}}[i, j] :H(P~)=−∑ijP~[i,j]logP~[i,j]
论文给出算法1,通过迭代算出
P
P
P.每次迭代都采用Sinkhorn算法,以便迭代更新类原型以找到它们的最佳估计
c. Updating weights
现在我们有了一个优化的分配矩阵
P
P
P,我们首先初始化权重
w
j
w_j
wj :
w
j
←
u
j
/
∥
u
j
∥
2
u
j
←
∑
i
P
[
i
,
j
]
f
φ
(
x
i
)
/
∑
i
P
[
i
,
j
]
\begin{gathered} \mathbf{w}_{j} \leftarrow \mathbf{u}_{j} /\left\|\mathbf{u}_{j}\right\|_{2} \\ \mathbf{u}_{j} \leftarrow \sum_{i} \mathbf{P}[i, j] f_{\varphi}\left(\mathbf{x}_{i}\right) / \sum_{i} \mathbf{P}[i, j] \end{gathered}
wj←uj/∥uj∥2uj←i∑P[i,j]fφ(xi)/i∑P[i,j]
接下来我们通过逻辑回归进一步调整权重,通过最小化以下损失来进行优化:
1
l
+
u
⋅
∑
i
∑
j
−
log
(
exp
(
S
[
i
,
j
]
)
∑
γ
=
1
n
exp
(
S
[
i
,
γ
]
)
)
⋅
P
[
i
,
j
]
\frac{1}{l+u} \cdot \sum_{i} \sum_{j}-\log \left(\frac{\exp (\mathbf{S}[i, j])}{\sum_{\gamma=1}^{n} \exp (\mathbf{S}[i, \gamma])}\right) \cdot \mathbf{P}[i, j]
l+u1⋅i∑j∑−log(∑γ=1nexp(S[i,γ])exp(S[i,j]))⋅P[i,j]
其中,
S
∈
R
(
l
+
u
)
×
n
\mathbf{S} \in \mathbb{R}^{(l+u) \times n}
S∈R(l+u)×n包含
l
o
g
i
t
s
logits
logits,其中的每个元素可以通过公式计算:
S
[
i
,
j
]
=
κ
⋅
w
j
T
f
φ
(
x
i
)
∥
w
j
∥
2
\mathbf{S}[i, j]=\kappa \cdot \frac{\mathbf{w}_{j}^{T} f_{\varphi}\left(\mathbf{x}_{i}\right)}{\left\|\mathbf{w}_{j}\right\|_{2}}
S[i,j]=κ⋅∥wj∥2wjTfφ(xi).注意
κ
\kappa
κ是一个尺度参数,用于调整与每个样本相关的置信度指标。它是与 W 共同学习的。
部署的逻辑回归自带超参数。在实验中,我们使用梯度步长为 0:1 和 0:8 的 SGD 优化器作为动量参数,并在 e 个 epoch 上进行训练。
d. Estimating the class minimum size
现在可以细化我们对下一次迭代的min-size
k
k
k 的估计.
为此,我们计算每个样本的预测标签:
ℓ
^
(
x
i
)
=
arg
max
j
(
P
[
i
,
j
]
)
\hat{\ell}\left(\mathbf{x}_{i}\right)=\arg \max _{j}(\mathbf{P}[i, j])
ℓ^(xi)=argmaxj(P[i,j]),可以看作是当前(临时)类的预测
然后计算 k = min j { k j } k=\min_{j}\left\{k_{j}\right\} k=minj{kj},其中 k j k_j kj代表类 j j j的样本数
Summary of the proposed method
论文方法的所有步骤在算法2中进行了总结