loss反向传播出错问题
在使用mse损失函数进行对抗攻击的时候,loss反向传播一直报错,最终改成如下形式才能够正常运行loss11 = F.mse_loss(logits, logits_target, reduction='none').sum(axis=1)loss12 = F.mse_loss(logits, logits_true, reduction='none').sum(axis=1)loss1 = 4 * loss11 - loss12loss = torch.mean(loss)optimizer