先投影并归一化特征,用 ECA 估计通道重要性,选 4 个通道构造 6 个不重复交叉乘积。乘积经过动态 Softsign 仿射变换,与投影后的 8 个原通道拼接,返回 14 通道特征。
[(2,8,5,7)] · c1=8, cs=4, layout=image;eval(2,14,5,7) · 8+4×3/2=14 个通道108 个参数(可训练 106;sum(p.numel()),包含非训练 Parameter,不计 buffer) · 卷积或 token 通道扩展forward() 数据流顺序拆解 · 点击任意子模块方块可同步查看对应源码切片先投影并归一化特征,用 ECA 估计通道重要性,选 4 个通道构造 6 个不重复交叉乘积。乘积经过动态 Softsign 仿射变换,与投影后的 8 个原通道拼接,返回 14 通道特征。
105 def forward(self, x: Tensor) -> Tensor:106 x = self.fc(x)107 x = self.norm_x(x)108 x_sel_ex = self._get_selected(x)109 x_sel_ex = self.norm(x_sel_ex)110 return torch.cat([x, x_sel_ex], dim=1)278 def forward(self,x):279 channel_axis=1 if self.layout=='image' else -1280 if x.ndim!=(4 if self.layout=='image' else 3) or x.shape[channel_axis]!=self.c1:282 if self.layout=='image' and self.training and x.dtype!=torch.float32:284 return self.block(x)
图示采用图像布局;输出通道数会增加,后续卷积需要接收 model.ce 个通道。
from AdaptiveCrossHadamardExpansion import AdaptiveCrossHadamardExpansion model = AdaptiveCrossHadamardExpansion(8, 4, layout='image') expanded = model(features)
Method 动机参考:以少量通道对的乘积显式引入二阶交互,再用有界非线性控制乘积幅度。
| 消融变体 | 结构配置 | 验证目的 |
|---|---|---|
| 一阶基线 | 仅投影特征 | 比较二阶项的任务收益 |
| 选通道数量 | cs=2 / 4 / 6 | 同时报告输出通道与计算量 |
| 幅度控制 | DySoft 与 Identity | 比较激活幅度;待运行对照 |