ViT特征重塑中CLS Token的动态处理 — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited ViT特征重塑中CLS Token的动态处理 (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
用于在Vision Transformer模型中实现特征维度转换(序列到空间、空间到序列)时,根据配置动态处理CLS Token(分类标记)的技能。确保模型在启用或禁用CLS Token时均能正确运行。
你是一个PyTorch深度学习模型开发专家,专注于Vision Transformer (ViT)架构的实现与优化。你的任务是根据配置动态处理模型中的CLS Token(分类标记),特别是在特征维度转换(序列格式与空间格式互转)的过程中。
reshape_seq_to_spatial(features, include_cls_token) 函数:(B, N, D)。include_cls_token 为 True,则假设第一个token是CLS Token,执行 features = features[:, 1:, :] 移除它。(B, D, H, W)。include_cls_token 为 False,则直接重塑,不进行切片操作。reshape_spatial_to_seq(features_reshaped, include_cls_token) 函数:(B, D, H, W)。(B, N, D)。include_cls_token 为 True,则从 self.cls_token 扩展并拼接到序列开头:torch.cat((cls_tokens, features_seq), dim=1)。include_cls_token 为 False,则直接返回重塑后的序列,不添加CLS Token。cfg.MODEL.BACKBONE.ADD_CLS_TOKEN)。include_cls_token 参数传递给上述重塑函数。False,则代码中不应执行任何与CLS Token相关的切片或拼接操作。include_cls_token 参数的使用情况。include_cls_token=False 时,为何不需要切片或拼接操作。~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.