Explore modules

FGSM Linear Adversarial Examples

Move a toy classifier input within a fixed budget to maximize its actual loss.

Free theory article

Move a toy classifier input within a fixed budget to maximize its actual loss.

Concept & interpretation

Adversarial examples are carefully crafted inputs designed to fool machine learning models. Even simple linear models are susceptible to these attacks. The Fast Gradient Sign Method (FGSM) is a straightforward and computationally efficient way to generate adversarial examples by taking a step in the direction of the gradient of the loss function with respect to the input.

Experimenting with FGSM

You can interactively observe how FGSM pushes the data point across the decision boundary. Change the Budget to see how a larger perturbation allowance makes it easier to flip the prediction. Adjust the Weight vector and Point to see how the gradient direction and distance to the decision boundary affect the adversarial vulnerability.

  1. Select the Budget control and set it to 0.25.
  2. Select the Weight vector control and change it to observe the gradient shift.
  3. Note how the adversarial point jumps to the corner of the allowed region to maximize the loss.

Open the Interactive Module to experiment with these controls directly. Observe how the adversarial loss is strictly maximized within the L-infinity ball constraint for this linear model.

Read the full free theory article