Domain Separation Networks-论文笔记

目的:what to transfer,以及如何有效避免negative transfer上。

假设:所有的域之间有着公有的特征(Shared)和私有的特征(Private),如果将各个域的私有特征也进行迁移的话就会造成负迁移(negative transfer)。

基于此,提出了Domain Separation Networks(DSNs)。

Domain Separation Networks (DSNs)

在这里插入图片描述

网络结构包含:

  • Shared Encoder E c ( x ) E_{c}(x) Ec(x): 提取共有特征,使得不同域之间迁移。
  • Private Source Encoder E p s ( x s ) E_{p}^{s}(x^{s}) Eps(xs) : 源域私有编码器, 用于提取源域数据私有特征。
  • Private Target Encoder E p t ( x t ) E_{p}^{t}(x^{t}) Ept(xt): 目标域私有编码器,用来提取目标域的私有特征。
  • Shared Decoder: 共享的解码器,输入时私有特征和共有特征,用于重构图像。
  • 源域分类器 G ( E c ( x s ) ) G\left(E_{c}\left(x^{s}\right)\right) G(Ec(xs)): 源域数据的分类器,输入是公有特征。训练完成之后,可以用来对目标域数据上分类。

其中, x s , x t x^s, x^t xs,xt分别表示源域和目标域输入,通过公有和私有编码器之后,分别输出 h p s , h c s h_p^s, h_c^s hps,hcs、 对应源域私有特征和共有特征, h p t , h c t h_p^t, h_c^t hpt,hct,对应目标域特征。

Loss

difference loss

为什么 E p t ( x ) , E p s ( x ) E_p^t(x), E_p^s(x) Ept(x),Eps(x)就能输出私有特征呢?

作者损失函数层面进行了限制,定义差异损失:
L difference  = ∥ H c s ⊤ H p s ∥ F 2 + ∥ H c t ⊤ H p t ∥ F 2 \mathcal{L}_{\text {difference }}=\left\|\mathbf{H}_{c}^{s \top} \mathbf{H}_{p}^{s}\right\|_{F}^{2}+\left\|\mathbf{H}_{c}^{t^{\top}} \mathbf{H}_{p}^{t}\right\|_{F}^{2} Ldifference =HcsHpsF2+HctHptF2
∥ ⋅ ∥ F 2 \|\cdot\|_{F}^{2} F2表示矩阵范式,而中间是 H c s ⊤ H p s \mathbf{H}_{c}^{\mathbf{s} \top} \mathbf{H}_{p}^{s} HcsHps,只有两个矩阵正交,范式才为0,所以这个损失鼓励私有特征和共有特征不相似,正交的时候最小。

Similarity loss

为什么 E c ( x ) E_c(x) Ec(x)就能输出共有特征?

为了保证源域和目标域是可迁移的,就要保证 h c t , h c s h_c^t, h_c^s hct,hcs的分布相似性。

注意是 h c t , h c s h_c^t, h_c^s hct,hcs的分布相似性,非向量相似性,因为本来就是不同输入,不能适得其输出相似。

作者用到了Gradient Reversal Layer (GRL):

简单讲就是找到一个函数Q(f(u)),使得梯度取反:
d d u Q ( f ( u ) ) = − d d u f ( u ) \frac{d}{d \mathbf{u}} Q(f(\mathbf{u}))=-\frac{d}{d \mathbf{u}} f(\mathbf{u}) dudQ(f(u))=dudf(u)

损失函数:
L similarity  D A N N = ∑ i = 0 N s + N t { d i log ⁡ d ^ i + ( 1 − d i ) log ⁡ ( 1 − d ^ i ) } \mathcal{L}_{\text {similarity }}^{\mathrm{DANN}}=\sum_{i=0}^{N_{s}+N_{t}}\left\{d_{i} \log \hat{d}_{i}+\left(1-d_{i}\right) \log \left(1-\hat{d}_{i}\right)\right\} Lsimilarity DANN=i=0Ns+Nt{dilogd^i+(1di)log(1d^i)}
使用了对抗学习的思想,通过一个域分类器 Z ( Q ( h c ) ; θ z ) , h c = E c ( x ; θ c ) Z\left(Q\left(\mathbf{h}_{c}\right) ; \boldsymbol{\theta}_{z}\right), \mathbf{h}_{c}=E_{c}\left(\mathbf{x} ; \boldsymbol{\theta}_{c}\right) Z(Q(hc);θz),hc=Ec(x;θc),来区分 h c t , h c s h_c^t, h_c^s hct,hcs是属于源域还是目标域。对于分类器的参数 θ z \theta_z θz通过梯度求导来最小化分类损失,让分类器分的更准。而通过加入Q,来使用GRL,使得在优化 θ c \theta_c θc的时候让分类器无法分辨输入属于source还是target。

Reconstruction loss

怎么保证 h p s , h p t , h c s , h c t h_{p}^{s}, h_{p}^{t}, h_{c}^{s},h_{c}^{t} hps,hpt,hcs,hct都是有意义的呢?例如 h p s = 0 , h p t = 0 , h c s = h c t = 1 h_{p}^{s}=0, \quad h_{p}^{t}=0, \quad h_{c}^{s}=h_{c}^{t}=1 hps=0,hpt=0,hcs=hct=1的时候,上述损失就可以达到0.

所以作者引入了重构损失。
L recon  = ∑ i = 1 N s L si  − mse  ( x i s , x ^ i s ) + ∑ i = 1 N t L s i − mse  ( x i t , x ^ i t ) L s i − m s e ( x , x ^ ) = 1 k ∥ x − x ^ ∥ 2 2 − 1 k 2 ( [ x − x ^ ] ⋅ 1 k ) 2 (3) \mathcal{L}_{\text {recon }}=\sum_{i=1}^{N_{s}} \mathcal{L}_{\text {si }_{-} \text {mse }}\left(\mathrm{x}_{i}^{s}, \hat{\mathrm{x}}_{i}^{s}\right)+\sum_{i=1}^{N_{t}} \mathcal{L}_{\mathrm{si}_{-} \text {mse }}\left(\mathrm{x}_{i}^{t}, \hat{\mathrm{x}}_{i}^{t}\right) \tag{3} \\ \mathcal{L}_{\mathrm{si}_{-} \mathrm{mse}}(\mathrm{x}, \hat{\mathrm{x}})=\frac{1}{k}\|\mathrm{x}-\hat{\mathrm{x}}\|_{2}^{2}-\frac{1}{k^{2}}\left([\mathrm{x}-\hat{\mathrm{x}}] \cdot 1_{k}\right)^{2} Lrecon =i=1NsLsi mse (xis,x^is)+i=1NtLsimse (xit,x^it)Lsimse(x,x^)=k1xx^22k21([xx^]1k)2(3)
其中k为输入x的像素个数,1k为长度为k的向量; ∥ ⋅ ∥ 2 2 \|\cdot\|_{2}^{2} 22是向量的平方模。

虽然均值平方误差损失传统上用于重建任务,但它会惩罚在缩放项下正确的预测。相反,尺度不变的均方误差抵消了像素对之间的差异。这允许模型学习复制被建模对象的整体形状,而不需要在输入的绝对颜色或强度上花费建模能力。

在实验中,作者用传统的均方误差损失代替式3中的尺度不变损失,验证了这种重构损失确实是正确的选择。

task loss

最后是分类器 G ( E c ( x s ) ) G\left(E_{c}\left(x^{s}\right)\right) G(Ec(xs))的分类损失:
L t a s k = − ∑ i = 0 N s y i s ⋅ log ⁡ y ^ i s \mathcal{L}_{\mathrm{task}}=-\sum_{i=0}^{N_{s}} \mathbf{y}_{i}^{s} \cdot \log \hat{\mathbf{y}}_{i}^{s} Ltask=i=0Nsyislogy^is
注意分类器的输入是共有特征,因此保证对于目标域,能够直接迁移过来,使用此分类器做分类任务。

Expriment

作者提供四组迁移的实验,五个数据集。Source-only表示没有进行迁移,只用源域数据进行训练得到的模型的精度;Target-only表示没有迁移,只有带标记的目标域数据进行训练得到的模型的精度;中间五行表示当目标域数据无标记,进行迁移之后各个模型的精度。

在这里插入图片描述

可以看出,DSNs算法还是有明显的提高。

Reference

  1. Domain Separation Networks.
  2. Domain-adversarial training of neural networks.
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

百川AI

你的鼓励将是我创作的最大动力

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

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

打赏作者

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

抵扣说明:

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

余额充值