← 返回模块库CVPR 2026上下采样 · 随机时空潜变量跃迁06_downsampling_upsampling/SPFNoiseCorrectedUpsampler.py

SPFNoiseCorrectedUpsamplerCorrelated Noise Correction for Pyramid Transitions

将生成潜变量做最近邻时空扩展,再用块内负相关高斯噪声及式20系数组合,修正金字塔阶段跃迁中的噪声协方差。模块在训练与评估中均随机采样。

本地单文件提炼 · Apache-2.0
实跑输入与配置
(2,3,4,3,5),spatial_factor=2、sigma_start=0.5;时空模式另传 temporal_indices=[0,2]。
真实前向输出
空间模式 (2,3,4,6,10);target_time=3 模式 (2,3,3,6,10),根钩子均已实跑。
精确参数量与状态
总参数 0;噪声在 float32 中采样再转换 latent dtype;n=r² 或 r²·Tout,要求 n>1。
① 空间与时间跃迁入口② 最近邻时空扩展③ 负相关块噪声采样④ 式20系数组合与返回生成潜变量入口2×3×4×3×5保留 T / 每样本选1片nearest 扩展空间: 2×3×4×6×10时空: 2×3×3×6×10负相关块噪声γ=-1/(n-1);ε=1e-6n=4 / 12式20系数s ← sigma_start 与 nscale;α随机潜变量输出scale·latent + α·noise空间 / 时空均已实跑空间模式保持T;target_time=3先选片,再扩展成目标3帧。噪声按块采样后转为 latent dtype;train/eval 都是随机跃迁。
按 forward() 数据流顺序拆解 · 点击任意子模块方块可同步查看对应源码切片
空间与时间跃迁入口最近邻时空扩展负相关块噪声采样式20系数组合与返回

全局总览SPFNoiseCorrectedUpsampler · 源码数据流

latents (2,3,4,3,5)→随机输出

这一步内部怎么算

空间路径保留4个时间片,把每个3×5网格扩展为6×10。时空路径先为每个样本选择一个粗时间片,再扩展为3×6×10。两种路径都采样等相关块噪声并与扩展 latent 组合,forward_hook 分别核对输出。

作者为什么这样设计

生成式金字塔切换分辨率时,直接复制潜变量会改变噪声相关性;此算子显式加入协方差修正,适合宿主流匹配生成过程的阶段转换。

对应真实源码切片

SPFNoiseCorrectedUpsampler.py · L235, L236, L237, L241, L243, L244, L249, L250, L251, L252, L253
235            latents=rearrange(latents,'b c t h w -> (b t) c h w')236            latents=F.interpolate(latents,size=(height,width),mode='nearest')237            latents=rearrange(latents,'(b t) c h w -> b c t h w',b=batch,t=time)241            latents=latents[torch.arange(batch,device=latents.device),:,temporal_indices,:,:].unsqueeze(2)243            latents=F.interpolate(latents,size=(time,height,width),mode='nearest')244        n=r*r if keep_scale else r*r*time249        s=e/(e+math.sqrt(n)*(1-e))250        alpha=(1-s)*math.sqrt((n-1)/n)251        scale=((1-s)+s*math.sqrt(n))/math.sqrt(n)252        noise=self.sample_block_noise(batch,channels,time,height,width,n,block_number,keep_scale,r,self.eps,latents.device)253        return scale*latents+alpha*noise.to(latents)

工程替换位点(3 行接入)

上下采样 · 随机时空潜变量跃迁

示例 latents=(B,C,T,H,W),temporal_indices 为每个样本的 long 时间索引。仅空间上采样时省略 target_time 和 temporal_indices。

from SPFNoiseCorrectedUpsampler import SPFNoiseCorrectedUpsampler
transition = SPFNoiseCorrectedUpsampler(2, target_time=3, sigma_start=0.5)
y = transition(latents, temporal_indices)

论文 Method 动机与消融设计

可直接参考写作

Method 动机参考:生成式金字塔切换分辨率时,直接复制潜变量会改变噪声相关性;此算子显式加入协方差修正,适合宿主流匹配生成过程的阶段转换。

消融变体结构配置验证目的
nearest 跃迁仅最近邻扩展比较复制后协方差与宿主生成指标
独立噪声对照相同系数,改用 iid 高斯区分噪声幅度与块负相关结构
完整修正nearest + 等相关块噪声 + 式20统计多随机种子的协方差与任务指标;本表为实验设计

常见 QA 专题

点击问题展开详解
Q1可当成确定性超分辨率层吗?+
此层处理生成潜变量的阶段跃迁,输出包含随机噪声。没有图像细节重建网络、可学习卷积或预训练超分权重。
Q2时间轴会直接乘 target_time 吗?+
不会。每个样本先选择一个输入时间片,再扩展到 target_time;本次 T=4、target_time=3,输出时间长度为3。
Q3为什么要求 n>1?+
γ=-1/(n-1) 定义了块负相关结构。n=1 时公式无定义,源码明确拒绝该配置。
Q4参数为0是否代表无计算与无梯度?+
仍执行插值、相关高斯采样与线性组合,有计算开销;输入 latent 的梯度可通过信号分支传播。
所属元设计范式:范式 06 · 时空金字塔与协方差修正
同类可对比模块:
SPFNoiseCorrectedUpsampler (CVPR 2026) · 源码级交互架构拆解