# Calculate the loss
loss = self.get_loss(logits, label)
# Calculate the gradients
grad = self.get_grad(loss, delta)
# Calculate the momentum
momentum = self.get_momentum(grad, momentum)
# Update adversarial perturbation
delta = self.update_delta(delta, data, momentum, self.alpha)
return delta.detach()`
您好,您的论文中所描述的梯度计算是计算了多个转换副本的平均梯度进行扰动更新,但是我在代码里并没有发现有这一操作的显示实现。您可以解答我的疑惑吗?十分感谢。
` for _ in range(self.epoch):
# Obtain the output
logits = self.get_logits(self.transform(data+delta, momentum=momentum))