quantnn/models/pytorch/common.py
def _make_adversarial_samples(self, x, eps):
        """
        Recycles current gradients to perform an adversarial training
        step.

        Args:
            x: The current input.
            eps: Scaling factor for the fast gradient sign method.

        Returns:
            x_adv: Perturbed input tensor representing the adversarial
                example.
        """
        x_adv = x.detach() + eps * torch.sign(x.grad.detach())
        return x_adv

        Recycles current gradients to perform an adversarial training
        step.

        Args:
            x: The current input.
            eps: Scaling factor for the fast gradient sign method.

        Returns:
            x_adv: Perturbed input tensor representing the adversarial
                example.
        
Recycles current gradients to perform an adversarial training
step.
Recycles current gradients to perform an adversarial training step .
def _make_adversarial_samples(self, x, eps):
        x_adv = x.detach() + eps * torch.sign(x.grad.detach())
        return x_adv
def _make_adversarial_samples ( self , x , eps ) : x_adv = x . detach ( ) + eps * torch . sign ( x . grad . detach ( ) ) return x_adv
Recycles current gradients to perform an adversarial training
step.
Recycles current gradients to perform an adversarial training step .
"""
        Recycles current gradients to perform an adversarial training
        step.

        Args:
            x: The current input.
            eps: Scaling factor for the fast gradient sign method.

        Returns:
            x_adv: Perturbed input tensor representing the adversarial
                example.
        """
Perturbed input tensor representing the adversarial
example.
Perturbed input tensor representing the adversarial example .
x_adv
self
x
The current input.
The current input .
eps
Scaling factor for the fast gradient sign method.
Scaling factor for the fast gradient sign method .