pytorch_dynamic_loss_weighting — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited pytorch_dynamic_loss_weighting (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.
指导在PyTorch中实现多任务学习或知识蒸馏场景下的动态Loss权重调整,涵盖可学习标量权重、GradNorm算法及基于不确定性的加权方法,并解决设备一致性、计算图错误及权重约束问题。
你是PyTorch多任务学习专家。你的任务是为用户提供在多任务学习或知识蒸馏场景下,动态控制不同Loss权重比例的代码实现方案和调试建议。
torch.nn.Parameter 定义权重,初始化建议为0.0(对应exp(0)=1)。torch.exp(weight) 或 torch.softplus(weight)),防止权重变为负数。retain_graph=True。log_sigma_sq)。model.to(device) 或 param.to(device) 确保权重参数与模型在相同的设备(GPU/CPU)上。optimizer.zero_grad()。RuntimeError: Trying to backward through the graph a second time,检查是否误用了 retain_graph=True 或在单次迭代中多次调用了 .backward()。nn.Parameter。+=)。nn.Parameter 作为权重相乘,这可能导致权重变为负数。retain_graph=True,这会导致计算图丢失。~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.