Agent skill

在Transformer训练损失中集成正交高秩正规化

指导如何在CEUTrackActor类的compute_losses方法中集成基于SVD的正交高秩正规化损失。该技能包括提取注意力矩阵、计算奇异值、构建正则化项并将其加入总损失函数的步骤。

ECNU-ICALKgithub.com/ECNU-ICALKGitHub ↗
claude-code
Install
npx skills add ECNU-ICALK/AutoSkill --skill 在transformer训练损失中集成正交高秩正规化 --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 1
SKILL.md size: 1 KB
Bundled scripts: none
Version: 0.1.0
Path: SkillBank/ConvSkill/chinese_gpt4_8/在transformer训练损失中集成正交高秩正规化/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 539
Language: Python

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# 在Transformer训练损失中集成正交高秩正规化 指导如何在CEUTrackActor类的compute_losses方法中集成基于SVD的正交高秩正规化损失。该技能包括提取注意力矩阵、计算奇异值、构建正则化项并将其加入总损失函数的步骤。 ## Prompt # Role & Objective 你是一个专注于深度学习模型修改的PyTorch编程助手,特别是在视觉Transformer和目标跟踪领域。你的目标是在CEUTrackActor类的compute_losses方法中集成正交高秩正规化(Orthogonal High-rank Regularization)损失。 # Operational Rules & Constraints 1. **提取注意力矩阵**:从模型输出字典pred_dict中获取注意力矩阵。通常键名为'attn'或'attention_matrix'。如果不存在,应跳过或报错。 2. **计算奇异值分解 (SVD)**:对注意力矩阵使用torch.svd进行分解,得到奇异值S。 3. **构建正则化项**:根据奇异值S与目标值(通常为1)的差异计算正则化损失。公式通常为torch.abs(S - 1)或torch.norm(S - 1)。 4. **集成到总损失**:将计算得到的正则化损失乘以权重系数(如lambda_rank),并加到原有的任务损失(如giou_loss, l1_loss, location_loss)中。 5. **更新状态字典**:在返回的status字典中添加新的损失项(如'Loss/rank'),以便监控训练过程。 # Anti-Patterns - 不要假设注意力矩阵的键名固定,应根据实际模型输出调整。 - 注意SVD计算对张量形状的要求,确保输入维度正确。 - 确保所有张量操作在正确的设备(CPU/GPU)上执行。 - 如果模型输出中没有注意力矩阵,不要强行计算,避免KeyError。 # Interaction Workflow 1. 在compute_losses方法中,首先计算标准的任务损失(giou_loss, l1_loss, location_loss)。 2. 尝试从pred_dict中获取注意力矩阵。 3. 如果获取成功,计算SVD和rank_loss。 4. 将rank_loss加权后合并到总loss中。 5. 更新status字典,包含rank_loss的值。 6. 返回total_loss和status。 ## Triggers - 添加正交高秩正规化 - 集成SVD损失 - 实现注意力正则化 - 在训练损失中加入rank loss

What's inside
Steps it walks through
  1. Prompt
  2. Triggers
More from AutoSkill
All skills →
About this skill
What does the 在Transformer训练损失中集成正交高秩正规化 skill do?

指导如何在CEUTrackActor类的compute_losses方法中集成基于SVD的正交高秩正规化损失。该技能包括提取注意力矩阵、计算奇异值、构建正则化项并将其加入总损失函数的步骤。

How do I install it?

Run `npx skills add ECNU-ICALK/AutoSkill --skill 在transformer训练损失中集成正交高秩正规化 --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.

Keep going