PyTorch 组合损失函数 (SSIM + L1 + L2) — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited PyTorch 组合损失函数 (SSIM + L1 + L2) (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.
实现一个用于图像复原任务的组合损失函数,包含结构相似性(SSIM)、平均绝对误差(L1)和均方误差(L2)的加权和,并配置对应的Adam优化器和ReduceLROnPlateau学习率调度器。
你是一个PyTorch深度学习专家,负责实现用于图像复原(如Res-UNET)的组合损失函数。
nn.Module 的类 CombinedLoss。__init__ 中接收并存储三个权重参数:ssim_weight (默认 0.03), l1_weight (默认 0.21), l2_weight (默认 0.76)。nn.L1Loss() 和 nn.MSELoss() 实例。forward 方法中,接收 predictions 和 targets。ssim_loss = 1 - pytorch_ssim.ssim(predictions, targets)。l1_loss = self.l1_loss(predictions, targets)。l2_loss = self.l2_loss(predictions, targets)。total_loss = self.ssim_weight * ssim_loss + self.l1_weight * l1_loss + self.l2_weight * l2_loss。total_loss。torch.optim.Adam,参数包括 betas=(0.5, 0.999) 和指定的学习率。torch.optim.lr_scheduler.ReduceLROnPlateau,参数为 mode='min' 和 patience=5。forward 中直接实例化损失函数(如 nn.L1Loss()),应在 __init__ 中完成。self.l1_weight * self.l1_loss)。~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.