Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsBlogPro
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges
  • Chrome Extension
  • Skill Manager

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Pytorch多分支线性层瓶颈降维实现

ASecurity

针对包含多个并行线性层的模块(如Multi_Context),通过引入隐藏层维度(hidden_dim)构建瓶颈结构,在保持输入输出维度不变的前提下减少参数量的代码修改任务。

2 stars
0 votes
0 copies
0 views
Added 9/27/2026
tools

Security Analysis

A100/100

Scanned 9/27/2026

$npx -y skills add David-Li0406/meta-skill-evloving --skill 'pytorch多分支线性层瓶颈降维实现' --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Pytorch多分支线性层瓶颈降维实现?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Pytorch多分支线性层瓶颈降维实现
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/david-li0406-pytorch-62e99604/badge)](https://www.skillsdirectory.com/skills/david-li0406-pytorch-62e99604)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
Files
SKILL.md
---
id: "3ed7d067-03eb-465b-823c-145b1e3a5ccc"
name: "PyTorch多分支线性层瓶颈降维实现"
description: "针对包含多个并行线性层的模块(如Multi_Context),通过引入隐藏层维度(hidden_dim)构建瓶颈结构,在保持输入输出维度不变的前提下减少参数量的代码修改任务。"
version: "0.1.0"
tags:
  - "PyTorch"
  - "模型优化"
  - "降维"
  - "参数量减少"
  - "线性层"
triggers:
  - "在linear层中降低维度"
  - "引入hidden_channels减少参数"
  - "修改Multi_Context进行降维"
  - "保持输入输出维度不变的情况下降维"
  - "实现bottleneck结构减少参数量"
---

# 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结构减少参数量

Attribution

David-Li0406David-Li0406
View sourceSee grades on GitHubMore from David-Li0406 →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

ucoz-landing-skill

Create and edit uCoz homepage landing pages via MCP: custom templates, hero sections, lead forms, navigation menus, SEO, and responsive layout. Includes a visual design system (style selection, layout/grid, section recipes, typography/spacing, color tokens, component states, icons, modern CSS/JS, motion, imagery, social proof, copy/voice, accessibility). Uses ucoz-mcp tools for templates, site file uploads, and site modules.

107 votes

Paperclip

Interact with the Paperclip control plane API for task coordination and governance. Use when checking assignments, updating issue status, posting comments, delegating work, managing routines, or calling Paperclip API endpoints.

953191 votes

Pptx

Presentation toolkit (.pptx). Create/edit slides, layouts, content, speaker notes, comments, for programmatic presentation creation and modification.

471861 votes

Daw Music

Digital Audio Workstation usage, music composition, interactive music systems, and game audio implementation for immersive soundscapes.

761 votes

Instantly Rdsthomas Mission Control

Instantly.ai cold email outreach API - manage campaigns, leads, accounts, and analytics. Use for cold email automation, lead management, campaign creation/monitoring, and email account warmup.

761 votes
View all in tools →