将时间 t t t、条件 c c c、图像patch后的加噪图像 x t x_t xt 作为输入,然后【通过 ϵ θ ( x t , t , c ) \epsilon_\theta(x_t, t, c) ϵθ(xt,t,c)】在 U-ViT模型中预测加入 x t x_t xt中的噪声。
受基于CNN的U-Net在扩散模型中的成功启发,U-ViT采用了类似的浅层和深层之间的长跳跃连接。
ϵ θ ( x t , t , c ) \epsilon_\theta(x_t, t, c) ϵθ(xt,t,c)的目标是像素级预测任务,对低级特征敏感。长跳跃连接为低级特征提供了捷径,使用长跳跃连接(long skip connections)连接浅层和深层,使浅层特征传递到深层,为深层网络提供更丰富的信息。
【可选项】U-ViT在输出之前添加一个3×3的卷积块。旨在防止transformer生成的图像中出现潜在的伪影(potential artifacts in images)。
位置编码使用 一维可学习嵌入(1-dimensional learnable position embedding) 是最佳选择(U-ViT和ViT、ViLT、DiT选择的位置编码一样,都是1D position embeddings,不同的是:DiT是不可学习的,ViT、ViLT和U-ViT是可学习的)。
问题 :哪种长跳跃连接方法更优? 实验设置 :考虑以下几种主分支 h m h_m hm 和长跳跃分支 h s h_s hs 的组合方法:
方法1 :将它们连接后执行线性投影: Linear(Concat ( h m , h s ) ) \text{Linear(Concat}(h_m, h_s)) Linear(Concat(hm,hs))
方法2 :直接相加: h m + h s h_m + h_s hm+hs
方法3 :线性投影 h s h_s hs 后相加: h m + Linear ( h s ) h_m + \text{Linear}(h_s) hm+Linear(hs)
方法4 :相加后进行线性投影: Linear ( h m + h s ) \text{Linear}(h_m + h_s) Linear(hm+hs)
方法5:不使用长跳跃连接。
结果:
方法1(连接后线性投影) 的性能最佳。该方法显著改变了表征信息,提升了模型性能。
方法2(直接相加) 表现较差,因为Transformer内部已有加法操作,导致无显著增益。
2. 时间信息的注入方式 (Feeding Time into the Network)
问题 :如何将时间 t t t 送入网络? 实验设置:
方法1 :将时间 t t t 作为一个Token输入(如图1所示)。
方法2 :通过自适应层归一化 (Adaptive LayerNorm, AdaLN) 融入时间信息:
AdaLN ( h , y ) = y s ⋅ LayerNorm ( h ) + y b \text{AdaLN}(h, y) = y_s \cdot \text{LayerNorm}(h) + y_b AdaLN(h,y)=ys⋅LayerNorm(h)+yb
其中, y s y_s ys 和 y b y_b yb 为时间嵌入的线性投影。
结果:
方法1(将时间视为Token) 效果更好,尽管实现简单。
3. 额外的卷积块 (Extra Convolutional Block)
问题 :Transformer后额外卷积块的位置对性能的影响? 实验设置:
方法1:在线性投影后添加一个3×3卷积块,将Token映射到图像Patch。
方法2:在线性投影前添加一个3×3卷积块。
方法3:不添加卷积块。
结果:
方法1(在线性投影后添加卷积块)性能略优。
4. Patch Embedding 的变体
问题 :哪种Patch Embedding方式更好? 实验设置:
方法1:使用线性投影将Patch映射为Token嵌入(原始方式)。
方法2:堆叠3×3卷积块,后接1×1卷积块,将图像映射为Token嵌入。
结果:
方法1(原始线性投影) 表现优于卷积堆叠方式。
5. 位置编码 (Position Embedding)
问题 :哪种位置编码更优? 实验设置:
方法1:一维可学习位置嵌入(ViT默认设置)。
方法2 :二维正弦位置嵌入,Patch的 position ( i , j ) \text{position}(i, j) position(i,j) 由 i i i 和 j j j 的正弦编码拼接得到,i i i 和 j j j 分别是二维网格中的行索引 和列索引。