Answers.Body: <p>input to output is linear refers to the input X i.e image and output is the output logits/softmax from the network.</p>
  <p>So how does linearity help in constructing adversarial examples? Imagine a simple logistic regressor and a simple 2D space. There is a definite boundary beyond which the label that the model(i.e logisitc regressor in this case) changes. So if we move perpendicular to the boundary (i.e the line represented by the model in this case) we can get to another class's space. So if we perturb the input in this direction, the model outputs wrong class. { Refer the slide with the title Adversarial Examples from Excessive Linearity for diagram }</p>
  <p>Now imagine the neural network trained on imagenet, there are so many boundaries and a small change can just shift change the class the model would predict. Now it is important to note that these subspaces of the image remain nearly the same if we train VGG or ResNet etc. So this explains how an adversarial example on one network effects another.</p>
  <p>You may ask how such small change can effect. this is because the vectors we deal it is not 2d or 3d, it is very large and small changes add up.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-01T10:09:45.963Z
Answers.Text: Computing the derivative of the loss function w.r.t the image would involve similar steps as of back-prop just that we would have the propagate the gradients from the 1st hidden layer to the input. In that case doesn't the gradient w.r.t image involve similar amount of non-linearity as the weights itself?
Answers.UserDisplayName: ANIRUDH BUVANESH
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-01T10:21:51.180Z
Answers.Text: Let's take a simple nn, 1st we multiply W.x, now multiplication is linear. Next say we apply ReLUs, they are linear too in the majority of the domain. Even sigmoid can be nearly considered linear in the non-saturating region. So we say dnn are very piecewise linear. i.e overall we can assume they're linear.  Yes some amount of nonlinearity is present but experiments have been done to show they act linearly. Note that I am only talking about the linearity of the network, not that of loss function.
Answers.UserDisplayName: Hrushi
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-01T10:44:40.537Z
Answers.Text: I get what you're saying, but the FGSM takes a step in the direction of the gradient of the loss w.r.t input image. And as you said if the inter-class decision boundary is linear then on moving farther in this direction would yield an adversarial example. Doesn't FGSM rely on linearity of gradients w.r.t image and not gradients of outputs w.r.t input [which is linear somewhat by your above explaination].
Answers.UserDisplayName: ANIRUDH BUVANESH
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-01T12:50:18.150Z
Answers.Text: The input image is like a reference, we don't take any gradient with respect to it, rather with the perturbation that is added to the input image. By the way, your question in title and OP are different. It would help if you can be a bit clear.
Answers.UserDisplayName: Hrushi
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-01T13:20:08.487Z
Answers.Text: Have edited the question.
Answers.UserDisplayName: ANIRUDH BUVANESH
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-01T08:52:28.617Z
Answers.LastActivityDate: 2021-01-01T08:52:28.617Z
Answers.UserDisplayName: Hrushi
Body: <p>I was having looking at this <a href="https://www.youtube.com/watch?v=CIfsB_EYsVI&amp;t=2039s" rel="nofollow noreferrer">lecture</a> by Ian Goodfellow and my doubt is around 18:00 timestamp where he explains generation of adversarial examples using FGSM.</p>
  <p>He mentions that the there is a linear relationship between the input to the model and the output as the activation functions are piece-wise linear with a small number of pieces. I'm not very clear what he means by input and output. Is he referring to inputs and outputs of a single layer or the input image and final output?</p>
  <p>He states that the relation between the parameters (weights) of a model and the output are non-linear which is what makes it difficult to train a neural network, thus it is much <strong>easier to find an adversarial example</strong>.</p>
  <p>Could someone explain what is linear in what? and how linearity helps in adversarial example construction?</p>
  <p>EDIT: As per my understanding FGSM method relies on the linearity of the loss function with respect to the input image. It constructs an adversarial example by perturbing the input in the direction of the gradient of the loss function w.r.t image. I am not able to understand why this works?</p>
  
Tags: <generative-adversarial-networks><generative-model>
Title: Why is it easier to construct adversarial examples relative to training neural networks?
UserDisplayName: ANIRUDH BUVANESH
ThreadText: # Why is it easier to construct adversarial examples relative to training neural networks?
  
  (Asked by: username_0 on 2020-12-29)
  
  I was having looking at this [lecture](https://www.youtube.com/watch?v=CIfsB_EYsVI&t=2039s) by Ian Goodfellow and my doubt is around 18:00 timestamp where he explains generation of adversarial examples using FGSM.
  
  He mentions that the there is a linear relationship between the input to the model and the output as the activation functions are piece-wise linear with a small number of pieces. I'm not very clear what he means by input and output. Is he referring to inputs and outputs of a single layer or the input image and final output?
  
  He states that the relation between the parameters (weights) of a model and the output are non-linear which is what makes it difficult to train a neural network, thus it is much **easier to find an adversarial example**.
  
  Could someone explain what is linear in what? and how linearity helps in adversarial example construction?
  
  EDIT: As per my understanding FGSM method relies on the linearity of the loss function with respect to the input image. It constructs an adversarial example by perturbing the input in the direction of the gradient of the loss function w.r.t image. I am not able to understand why this works?
  
  **Tags:** generative-adversarial-networks, generative-model
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-01-01. Score: 1
  
  input to output is linear refers to the input X i.e image and output is the output logits/softmax from the network.
  
  So how does linearity help in constructing adversarial examples? Imagine a simple logistic regressor and a simple 2D space. There is a definite boundary beyond which the label that the model(i.e logisitc regressor in this case) changes. So if we move perpendicular to the boundary (i.e the line represented by the model in this case) we can get to another class's space. So if we perturb the input in this direction, the model outputs wrong class. { Refer the slide with the title Adversarial Examples from Excessive Linearity for diagram }
  
  Now imagine the neural network trained on imagenet, there are so many boundaries and a small change can just shift change the class the model would predict. Now it is important to note that these subspaces of the image remain nearly the same if we train VGG or ResNet etc. So this explains how an adversarial example on one network effects another.
  
  You may ask how such small change can effect. this is because the vectors we deal it is not 2d or 3d, it is very large and small changes add up.
  
  > **Comments:**
  > **username_0**: Computing the derivative of the loss function w.r.t the image would involve similar steps as of back-prop just that we would have the propagate the gradients from the 1st hidden layer to the input. In that case doesn't the gradient w.r.t image involve similar amount of non-linearity as the weights itself?  
  > **username_1**: Let's take a simple nn, 1st we multiply W.x, now multiplication is linear. Next say we apply ReLUs, they are linear too in the majority of the domain. Even sigmoid can be nearly considered linear in the non-saturating region. So we say dnn are very piecewise linear. i.e overall we can assume they're linear.  Yes some amount of nonlinearity is present but experiments have been done to show they act linearly. Note that I am only talking about the linearity of the network, not that of loss function.  
  > **username_0**: I get what you're saying, but the FGSM takes a step in the direction of the gradient of the loss w.r.t input image. And as you said if the inter-class decision boundary is linear then on moving farther in this direction would yield an adversarial example. Doesn't FGSM rely on linearity of gradients w.r.t image and not gradients of outputs w.r.t input [which is linear somewhat by your above explaination].  
  > **username_1**: The input image is like a reference, we don't take any gradient with respect to it, rather with the perturbation that is added to the input image. By the way, your question in title and OP are different. It would help if you can be a bit clear.  
  > **username_0**: Have edited the question.  
  
  ---
  
  