zl程序教程

您现在的位置是:首页 >  IT要闻

当前栏目

迁移学习(JDDA) 《Joint domain alignment and discriminative feature learning for unsupervised deep domain adaptation》

2023-03-20 15:31:04 时间

论文信息

论文标题:Joint domain alignment and discriminative feature learning for unsupervised deep domain adaptation
论文作者:Chao Chen , Zhihong Chen , Boyuan Jiang , Xinyu Jin
论文来源:AAAI 2019
论文地址:download 
论文代码:download
引用次数:175

1 Introduction

  近年来,大多数工作集中于减少不同领域之间的分布差异来学习共享的特征表示,由于所有的域对齐方法只能减少而不能消除域偏移,因此分布在簇边缘或远离相应类中心的目标域样本很容易被从源域学习到的超平面误分类。为缓解这一问题,提出联合域对齐和判别特征学习,有利于 域对齐 和 分类。具体提出了一种基于实例的判别特征学习方法和一种基于中心的判别特征学习方法,两者均保证了域不变特征具有更好的类内紧凑性和类间可分性。大量的实验表明,在共享特征空间中学习鉴别特征可以显著提高性能。
  域适应,关注如何从源域的大量标记样本和目标域有限或没有标记的目标样本学习分类,可以分为如下三种方法:

    • feature-based domain adaptation
    • instance-based domain adaptation
    • classifier-based domain adaptation

2 Method

  总体框架如下:

    

2.1 Problem statement

  In this work, following the settings of unsupervised domain adaptation, we define the labeled source data as  $mathcal{D}^{s}=  left{mathbf{X}^{s}, mathbf{Y}^{s} ight}=left{left(oldsymbol{x}_{i}^{s}, y_{i}^{s} ight) ight}_{i=1}^{n_{s}}$  and define the unlabeled target data as  $mathcal{D}^{t}=left{mathbf{X}^{t} ight}=left{oldsymbol{x}_{i}^{t} ight}_{i=1}^{n_{t}}$ , where  $mathbf{x}^{s}$  and  $mathbf{x}^{t}$  have the same dimension  $mathbf{x}^{s(t)} in mathbb{R}^{d}$ . Let  $oldsymbol{Theta}$  denotes the shared parameters to be learned.  $mathbf{H}_{s} in mathbb{R}^{b imes L}$  and  $mathbf{H}_{t} in mathbb{R}^{b imes L}$  denote the learned deep features in the bottleneck layer regard to the source stream and target stream, respectively.  $b$  indicates the batch size during the training stage and  $L$  is the number of hidden neurons in the bottleneck layer. Then, the networks can be trained by minimizing the following loss function.

    $egin{array}{l}mathcal{L}left(oldsymbol{Theta} mid mathbf{X}_{s}, mathbf{Y}_{s}, mathbf{X}_{t} ight)=mathcal{L}_{s}+lambda_{1} mathcal{L}_{c}+lambda_{2} mathcal{L}_{d}    quadquad(1)\mathcal{L}_{s}=frac{1}{n_{s}} sum_{i=1}^{n_{s}} cleft(oldsymbol{Theta} mid oldsymbol{x}_{i}^{s}, y_{i}^{s} ight)  quadquad quadquad quadquadquadquad(2)\mathcal{L}_{c}=C O R A Lleft(mathbf{H}_{s}, mathbf{H}_{t} ight)  quadquad quadquad quadquad quadquad(3)\mathcal{L}_{d}=mathcal{J}_{d}left(oldsymbol{Theta} mid mathbf{X}^{s}, mathbf{Y}^{s} ight)  quadquad quadquad quadquadquadquad quadquad(4)end{array}$

  其中

    • $mathcal{L}_{s}$ 代表源域分类损失;
    • $mathcal{L}_{c}=operatorname{CORAL}left(mathbf{H}_{s}, mathbf{H}_{t} ight) $ 表示通过相关性对齐度量的域差异损失;
    • $mathcal{J}_{d}left(oldsymbol{Theta} mid mathbf{X}^{s}, mathbf{Y}^{s} ight) $ 代表鉴别损失,保证了域不变特征具有更好的类内紧致性和类间可分性;

2.2 Correlation Alignment ($ ext{CORAL}$)

  为学习域不变特征,通过对齐源特征和目标特征的协方差来减少域差异。域差异损失如下:

    $mathcal{L}_{c}=operatorname{CORAL}left(mathbf{H}_{s}, mathbf{H}_{t} ight)=frac{1}{4 L^{2}}left|operatorname{Cov}left(mathbf{H}_{s} ight)-operatorname{Cov}left(mathbf{H}_{t} ight) ight|_{F}^{2}quadquad(5)$

  其中:

    • $|cdot|_{F}^{2}$ 为矩阵 $ ext{Frobenius}$ 范数;  
    • $operatorname{Cov}left(mathbf{H}_{s} ight)$ 和 $operatorname{Cov}left(mathbf{H}_{t} ight)$ 表示 $ ext{bottleneck layer}$ 中源特征和目标特征的协方差矩阵;  
      • $operatorname{Cov}left(mathbf{H}_{s} ight)=mathbf{H}_{s}^{ op} mathbf{J}_{b} mathbf{H}_{s}$
      • $operatorname{Cov}left(mathbf{H}_{t} ight)=mathbf{H}_{t}^{ op} mathbf{J}_{b} mathbf{H}_{t}$
        • $mathbf{J}_{b}=mathbf{I}_{b}-frac{1}{b} mathbf{1}_{n} mathbf{1}_{n}^{T^{s}}$ 是 $ ext{centralized matrix}$;
        • $mathbf{1}_{b} in mathbb{R}^{b}$ 全 $1$ 列向量;
        • $b$ 是批大小;

  注意,训练过程是通过小批量 $ ext{SGD}$ 实现的,因此,在每次迭代中,只有一批训练样本被对齐。

2.3 Discriminative Feature Learning

  为学习更具判别性的特征,提出两种判别特征学习方法:基于实例的判别特征学习基于中心的判别特征学习

  注意,整个训练阶段都是基于小批量 $ ext{SGD}$ 的。因此,下面给出的鉴别损失是基于一批样本的。

2.3.1 Instance-Based Discriminative Loss

  基于实例的判别特征学习的动机是:同一类的样本在特征空间中应该尽可能地接近,不同类的样本之间应有较大距离。

  基于实例的判别损失 $mathcal{L}_{d}^{I}$ 可以表示为:

    $mathcal{J}_{d}^{I}left(mathbf{h}_{i}^{s}, mathbf{h}_{j}^{s} ight)=left{egin{array}{ll}max left(0,left|mathbf{h}_{i}^{s}-mathbf{h}_{j}^{s} ight|_{2}-m_{1} ight)^{2} & C_{i j}=1 \max left(0, m_{2}-left|mathbf{h}_{i}^{s}-mathbf{h}_{j}^{s} ight|_{2} ight)^{2} & C_{i j}=0end{array} ight.quadquad(6)$
    $mathcal{L}_{d}^{I}=sumlimits _{i, j=1}^{n_{s}} mathcal{J}_{d}^{I}left(mathbf{h}_{i}^{s}, mathbf{h}_{j}^{s} ight)quadquad(7)$

  其中:

    • $mathbf{H}_{s}=left[mathbf{h}_{1}^{s} ; mathbf{h}_{2}^{s} ; cdots ; mathbf{h}_{b}^{s} ight] $;
    • $C_{i j}=1$ 表示 $mathbf{h}_{i}^{s}$ 和 $mathbf{h}_{j}^{s}$ 来自同一个类,$C_{i j}=0$ 表示 $mathbf{h}_{i}^{s}$ 和 $mathbf{h}_{j}^{s}$ 来自不同的类;
    • $m_{2}$ 大于 $m_{1}$;

  从 $ ext{Eq.6}$、$ ext{Eq.7}$ 中可以看出,判别损失会使类内样本之间的距离不超过 $m_{1}$,而类间样本之间的距离至少 $m_{2}$。

  为简洁起见,将深度特征 $mathbf{H}_{s}$ 的成对距离表示为 $mathbf{D}^{H} in mathbb{R}^{b imes b}$,其中 $mathbf{D}_{i j}^{H}=left|mathbf{h}_{i}^{s}-mathbf{h}_{j}^{s} ight|_{2}$。设 $mathbf{L} in mathbb{R}^{b imes b}$ 表示指示器矩阵,如果第 $i$ 个样本和第 $j$ 个样本来自同一个类,则表示 $mathbf{L}_{i j}=1$,如果它们来自不同的类,则表示 $mathbf{L}_{i j}=0$。然后,基于实例的判别损失可简化为:

    $egin{aligned}mathcal{L}_{d}^{I} =alphaleft|max left(0, mathbf{D}^{H}-m_{1} ight)^{2} circ mathbf{L} ight|_{ ext {sum }}+left|max left(0, m_{2}-mathbf{D}^{H} ight)^{2} circ(1-mathbf{L}) ight|_{s u m}end{aligned}quadquad(8)$

2.3.2 Center-Based Discriminative Loss

  基于实例的鉴别损失 需要计算样本之间的成对距离,计算成本较高。受 Center Loss 惩罚每个样本到相应类中心的距离的启发,本文提出基于中心的判别特征学习:

    $egin{array}{c}mathcal{L}_{d}^{C}=eta sumlimits _{i=1}^{n_{s}} max left(0,left|mathbf{h}_{i}^{s}-mathbf{c}_{y_{i}} ight|_{2}^{2}-m_{1} ight)+sumlimits_{i, j=1, i eq j}^{c} max left(0, m_{2}-left|mathbf{c}_{i}-mathbf{c}_{j} ight|_{2}^{2} ight)end{array}quadquad(9)$

  其中:

    • $eta$ 为权衡参数;
    • $m_{1}$ 和 $m_{2}$ 为两个约束边距 $left(m_{1}<m_{2} ight)$;
    • $mathbf{c}_{y_{i}} in mathbb{R}^{d}$ 表示第 $y_{i}$ 类的质心,$y_{i} in{1,2, cdots, c}$,$c$ 表示类数;  

  理想情况下,类中心 $mathbf{c}_{i}$ 应通过平均所有样本的深层特征来计算。但由于本文是基于小批量进行更新的,因此很难用整个训练集对深度特征进行平均。在此,本文做了一个必要的修改,对于 $ ext{Eq.9}$ 中判别损失的第二项,用于度量类间可分性的 $mathbf{c}_{i}$ 和 $mathbf{c}_{j}$ 是通过对当前一批深度特征进行平均来近似计算的,称之为 “批类中心” 。相反,用于测量类内紧致性的 $mathbf{c}_{y_{i}}$ 应该更准确,也更接近 “全局类中心”。因此,在每次迭代中更新 $mathbf{c}_{y_{i}}$ 为

    $egin{array}{l}Delta mathbf{c}_{j}=frac{sumlimits _{i=1}^{b} deltaleft(y_{i}=j ight)left(mathbf{c}_{j}-mathbf{h}_{i}^{s} ight)}{1+sumlimits_{i=1}^{b} deltaleft(y_{i}=j ight)} quadquad(10) \mathbf{c}_{j}^{t+1}=mathbf{c}_{j}^{t}-gamma cdot Delta mathbf{c}_{j}^{t}quadquad(11)end{array}$

  “全局类中心” 在第一次迭代中被初始化为“批类中心”,在每次迭代中通过 $ ext{Eq.10}$、$ ext{Eq.11}$ 进行更新,其中 $gamma$ 是更新“全局类中心”的学习速率。为简洁起见,$ ext{Eq.9}$ 可以简化为

    $egin{array}{r}mathcal{L}_{d}^{C}=etaleft|max left(0, mathbf{H}^{c}-m_{1} ight) ight|_{ ext {sum }}+ left|max left(0, m_{2}-mathbf{D}^{c} ight) circ mathbf{M} ight|_{ ext {sum }}end{array}$

  其中:

    • $mathbf{H}^{c}=left[mathbf{h}_{1}^{c} ; mathbf{h}_{2}^{c} ; ldots ; mathbf{h}_{b}^{c} ight]$,$mathbf{h}_{i}^{c}=left|mathbf{h}_{i}^{s}-mathbf{c}_{y_{i}} ight|_{2}^{2}$ 表示第 $i$ 个样本深层特征与其对应的中心 $mathbf{c}_{y_{i}}$ 之间的距离;
    • $  mathbf{D}^{c} in mathbb{R}^{c imes c} $ 表示“批类中心”的成对距离,即 $mathbf{D}_{i j}^{c}=left|mathbf{c}_{i}-mathbf{c}_{j} ight|_{2}^{2} $;

  不同于 $ ext{Center Loss }$,它只考虑类内的紧致性,本文不仅惩罚了深度特征与其相应的类中心之间的距离,而且在不同类别的中心之间加强了较大的边际。

2.4 Training

  所提出的 $ ext{Instance-Based joint discriminative domain adaptation (JDDA-I)}$和 $ ext{Center-Based joint discriminative domain adaptation (JDDA-C)}$ 都可以通过小批量SGD轻松实现。对于 $ ext{JDDA-I}$,总损失为  $mathcal{L}=mathcal{L}_{s}+lambda_{1} mathcal{L}_{c}+lambda_{2}^{I} mathcal{L}_{d}^{I}$,$mathcal{L}_{c}$ 代表源域的分类损失。因此,参数 $Theta$ 可以通过标准的反向传播直接更新

    $Theta^{t+1}=Theta^{t}-eta frac{partialleft(mathcal{L}_{s}+lambda_{1} mathcal{L}_{c}+lambda_{2}^{I} mathcal{L}_{d}^{I} ight)}{partial mathbf{x}_{mathbf{i}}}quadquad(13)$ 

  由于 “global class center” 不能通过一批样本来计算,因此 $ ext{JDDA-C}$ 必须在每次迭代中同时更新 $Theta$ 和“全局类中心”:
    $oldsymbol{Theta}^{t+1}=oldsymbol{Theta}^{t}-eta frac{partialleft(mathcal{L}_{s}+lambda_{1} mathcal{L}_{c}+lambda_{2}^{C} mathcal{L}_{d}^{C} ight)}{partial mathbf{x}_{mathbf{i}}}$
    $mathbf{c}_{j}^{t+1}=mathbf{c}_{j}^{t}-gamma cdot Delta mathbf{c}_{j}^{t} quad j=1,2, cdots, cquadquad(14)$ 

3 Experiments

 

 

 

====