先去线性趋势并分析频谱,以谱平坦度锚定软滤波掩码,重建误差形成样本噪声分数。分数经批内归一化与可学习灵敏度映射为丢弃率,再用直通掩码实施样本自适应 dropout。
[4×24×3, 4]8 个总参数,8 个 requires_grad 参数(sum(p.numel());不计 buffer)。配置:L=24,C=3,p_min=.1,p_max=.5,robust_ols,实例幅值归一化,SFM锚定,训练态。用途:时序预测的样本自适应 dropout。forward() 数据流顺序拆解 · 点击任意子模块方块可同步查看对应源码切片先去线性趋势并分析频谱,以谱平坦度锚定软滤波掩码,重建误差形成样本噪声分数。分数经批内归一化与可学习灵敏度映射为丢弃率,再用直通掩码实施样本自适应 dropout。 本页尺寸来自本地源码示例的 CPU 前向:子模块用 forward_hook 记录,函数式算子的中间张量在真实执行时读取;全部尺寸包含批维。
423 def compute_dropout_rates(self, inputs): 424 if inputs.ndim != 3 or inputs.shape[1:] != (self.seq_len, self.num_features):425 raise ValueError('inputs must have configured BLC shape.') 426 noise_scores = self.noise_scorer(inputs)427 min_score, max_score = noise_scores.min(), noise_scores.max()428 score_range = max_score - min_score429 if score_range > 1e-6: 430 normalized = (noise_scores - min_score) / score_range431 else: 432 normalized = torch.full_like(noise_scores, 0.5)433 normalized = torch.tanh(normalized * F.softplus(self.sensitivity))434 return self.p_min + (self.p_max - self.p_min) * normalized
已准备 x=(B,24,3)。训练前构造模块并加入优化器;序列长度与特征数由构造参数固定。 示例配置已在 CPU 运行源码内置检查。消融表列的是建议实验,尚无下游任务指标。
from DropoutTSAdaptiveDropout import DropoutTS regularizer = DropoutTS(24,3) dropped, rates = regularizer(x)
Method 动机参考:将每个样本的频谱重建难度转为正则化强度,使丢弃率可随输入及训练更新变化。噪声评估分支与实际丢弃分支读取同一输入。
| 消融变体 | 结构配置 | 验证目的 |
|---|---|---|
| 固定丢弃率 | 普通Dropout或固定样本率 | 建立相同正则化量级对照 |
| 无SFM锚定 | use_sfm_anchor=False | 比较可学习固定阈值与样本SFM阈值 |
| 完整自适应率 | 重建评分 + 灵敏度 + STE | 比较预测质量、各样本rate及梯度 |