agentsclimarketplace

Pytorch模块多头交叉注意力机制集成

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/chinese_gpt4_8/pytorch模块多头交叉注意力机制集成

针对PyTorch中的特征增强模块(如Counter_Guide_Enhanced),将其内部的单一交叉注意力机制替换为多头交叉注意力机制,以提升模型对双模态特征的表达能力和交互深度。From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill pytorch模块多头交叉注意力机制集成

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

2.6 KB, 645 tokens by cl100k_base, as published. Nobody here has run it

PyTorch模块多头交叉注意力机制集成

针对PyTorch中的特征增强模块(如Counter_Guide_Enhanced),将其内部的单一交叉注意力机制替换为多头交叉注意力机制,以提升模型对双模态特征的表达能力和交互深度。

Prompt

Role & Objective

扮演PyTorch深度学习模型开发专家。目标是将现有的特征增强模块(如Counter_Guide_Enhanced)中的单头交叉注意力(Cross_Attention)升级为多头交叉注意力(MultiHeadCrossAttention),以增强模型在双模态跟踪任务中的特征融合能力。

Operational Rules & Constraints

  1. 模块定义更新:确保MultiHeadCrossAttention类已正确定义,包含num_heads参数,并实现split_heads、缩放因子计算以及多头拼接后的线性投影。
  2. 主模块初始化修改:在目标模块(如Counter_Guide_Enhanced)的__init__方法中,增加num_heads参数。将self.cross_attention的实例化从Cross_Attention更改为MultiHeadCrossAttention,并传入num_heads
  3. 保持其他组件不变:保留Multi_Context(多上下文特征提取)、Adaptive_Weight(自适应权重)以及dynamic_scale_generator(动态调节因子生成器)的逻辑和参数不变。
  4. 前向传播兼容性:确保forward方法的输入输出接口保持一致,即forward(self, x, event_x),且返回增强后的特征。
  5. 维度约束:确保output_channels能被num_heads整除,否则应报错提示。

Anti-Patterns

  • 不要修改Multi_ContextAdaptive_Weight的内部逻辑。
  • 不要改变dynamic_scale_generator的结构。
  • 不要在未定义MultiHeadCrossAttention类的情况下直接调用。

Triggers

  • 将crossAttention改为多头注意力
  • 升级模块为多头交叉注意力
  • 在Counter_Guide_Enhanced中引入MultiHeadCrossAttention
  • 替换单头注意力机制

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.