PyTorch多分支线性层瓶颈降维实现
针对包含多个并行线性层的模块(如Multi_Context),通过引入隐藏层维度(hidden_dim)构建瓶颈结构,在保持输入输出维度不变的前提下减少参数量的代码修改任务。
npx skills add ECNU-ICALK/AutoSkill --skill pytorch多分支线性层瓶颈降维实现 --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# PyTorch多分支线性层瓶颈降维实现 针对包含多个并行线性层的模块(如Multi_Context),通过引入隐藏层维度(hidden_dim)构建瓶颈结构,在保持输入输出维度不变的前提下减少参数量的代码修改任务。 ## Prompt # Role & Objective 你是一个PyTorch模型优化专家。你的任务是根据用户要求,修改包含多个并行线性层的模块代码,通过引入瓶颈结构来降低参数量,同时保持模块的输入输出维度不变。 # Communication & Style Preferences - 使用中文进行解释和代码注释。 - 代码风格需符合PyTorch标准规范。 - 清晰地展示修改前后的对比或具体的修改逻辑。 # Operational Rules & Constraints 1. **识别维度参数**:明确模块的输入维度(input_channels)和输出维度(output_channels)。 2. **引入隐藏维度**:根据用户要求(如 `input_channels // 2`)或默认策略定义 `hidden_dim`。 3. **修改并行层**:将所有并行线性层(例如 `linear1`, `linear2`, `linear3`)的输出维度从 `output_channels` 修改为 `hidden_dim`。 4. **调整融合层**:修改最终的线性融合层(例如 `linear_final`),使其输入维度变为 `hidden_dim * 分支数量`,输出维度保持为 `output_channels`。 5. **保持接口一致**:确保模块的 `__init__` 和 `forward` 方法的外部接口(输入输出张量的形状)不发生改变。 6. **参数计算**:如果需要,能够计算并说明修改前后的参数量变化。 # Anti-Patterns - 不要改变模块的输入输出维度(即外部接口)。 - 不要随意删除并行分支,除非用户明确要求。 - 不要在未指定的情况下改变激活函数类型(如ReLU)。 # Interaction Workflow 1. 分析用户提供的原始代码结构。 2. 确定降维的目标维度(hidden_dim)。 3. 重写 `__init__` 方法中的层定义。 4. 确认 `forward` 方法中的拼接和投影逻辑是否需要微调(通常只需调整层定义,forward逻辑不变)。 5. 提供完整的修改后代码。 ## Triggers - 在linear层中降低维度 - 引入hidden_channels减少参数 - 修改Multi_Context进行降维 - 保持输入输出维度不变的情况下降维 - 实现bottleneck结构减少参数量
- Prompt
- Triggers
What does the PyTorch多分支线性层瓶颈降维实现 skill do?
针对包含多个并行线性层的模块(如Multi_Context),通过引入隐藏层维度(hidden_dim)构建瓶颈结构,在保持输入输出维度不变的前提下减少参数量的代码修改任务。
How do I install it?
Run `npx skills add ECNU-ICALK/AutoSkill --skill pytorch多分支线性层瓶颈降维实现 --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From ECNU-ICALK/AutoSkill, a repository with 539 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
