Lecture 16 | Adversarial Examples and Adversarial Training — Transcript
Full transcript
- 0:08- Okay, sounds like it is.
- 0:10I'll be telling you about adversarial examples
- 0:12and adversarial training today.
- 0:15Thank you.
- 0:18As an overview, I will start off by telling you
- 0:20what adversarial examples are,
- 0:22and then I'll explain why they happen,
- 0:26why it's possible for them to exist.
- 0:28I'll talk a little bit about how adversarial examples
- 0:31pose real world security threats,
- 0:33that they can actually be used to compromise
- 0:36systems built on machine learning.
- 0:38I'll tell you what the defenses are so far,
- 0:41but mostly defenses are an open research problem
- 0:43that I hope some of you will move on to tackle.
- 0:47And then finally I'll tell you
- 0:49how to use adversarial examples
- 0:50to improve other machine learning algorithms
- 0:53even if you want to build a machine learning algorithm
- 0:56that won't face a real world adversary.
- 1:00Looking at the big picture and the context for this lecture,
- 1:05I think most of you are probably here
- 1:07because you've heard how incredibly powerful
- 1:10and successful machine learning is,
- 1:12that very many different tasks
- 1:14that could not be solved with software before
- 1:17are now solvable thanks to deep learning
- 1:20and convolutional networks and gradient descent.
- 1:23All of these technologies that are working really well.
- 1:27Until just a few years ago,
- 1:28these technologies didn't really work.
- 1:30In about 2013, we started to see
- 1:33that deep learning achieved human level performance
- 1:37at a lot of different tasks.
- 1:39We saw that convolutional nets
- 1:40could recognize objects and images
- 1:43and score about the same as people in those benchmarks,
- 1:47with the caveat that part of the reason that
- 1:49algorithms score as well as people
- 1:51is that people can't tell
- 1:52Alaskan Huskies from Siberian Huskies very well,
- 1:55but modulo the strangeness of the benchmarks
- 1:58deep learning caught up to about human level performance
- 2:01for object recognition in about 2013.
- 2:05That same year, we also saw that object recognition
- 2:08applied to human faces caught up to about human level.
- 2:12That suddenly we had computers
- 2:14that could recognize faces about as well as
- 2:17you or I could recognize faces of strangers.
- 2:21You can recognize the faces of your friends and family
- 2:24better than a computer, but when you're dealing
- 2:27with people that you haven't had a lot of experience with
- 2:30the computer caught up to us in about 2013.
- 2:34We also saw that computers caught up
- 2:36to humans for reading type written fonts in photos
- 2:41in about 2013.
- 2:42It even got the point that we could no longer use CAPTCHAs
- 2:46to tell whether a user of a webpage is human or not
- 2:50because the convolutional network
- 2:52is better at reading obfuscated text than a human is.
- 2:56So with this context today
- 2:58of deep learning working really well
- 3:00especially for computer vision
- 3:02it's a little bit unusual to think about
- 3:05the computer making a mistake.
- 3:07Before about 2013, nobody was ever surprised
- 3:10if the computer made a mistake.
- 3:12That was the rule not the exception,
- 3:14and so today's topic which is all about
- 3:16unusual mistakes that deep learning algorithms make
- 3:20this topic wasn't really a serious avenue of study
- 3:24until the algorithms started to work well most of the time,
- 3:28and now people study the way that they break
- 3:31now that that's actually the exception rather than the rule.
- 3:36An adversarial example is an example
- 3:39that has been carefully computed to be misclassified.
- 3:43In a lot of cases we're able to make the new image
- 3:45indistinguishable to a human observer
- 3:48from the original image.
- 3:50Here, I show you one where we start with a panda.
- 3:52On the left this is a panda
- 3:54that has not been modified in any way,
- 3:57and the convolutional network trained on the image
- 3:59in that dataset is able to recognize it as being a panda.
- 4:03One interesting thing is that the model
- 4:05doesn't have a whole lot of confidence in that decision.
- 4:08It assigns about 60% probability
- 4:10to this image being a panda.
- 4:13If we then compute exactly the way
- 4:16that we could modify the image
- 4:17to cause the convolutional network to make a mistake
- 4:20we find that the optimal direction
- 4:23to move all the pixels is given by this image in the middle.
- 4:27To a human it looks a lot like noise.
- 4:29It's not actually noise.
- 4:31It's carefully computed as a function
- 4:33of the parameters of the network.
- 4:34There's actually a lot of structure there.
- 4:36If we multiply that image of the structured attack
- 4:41by a very small coefficient and add it to the original panda
- 4:45we get an image that a human can't tell
- 4:48from the original panda.
- 4:49In fact, on this slide there is no difference
- 4:52between the panda on the left
- 4:54and the panda on the right.
- 4:56When we present the image to convolutional network
- 4:58we use 32-bit floating point values.
- 5:01The monitor here can only display eight bits
- 5:05of color resolution, and we have made a change
- 5:07that's just barely too small
- 5:09to affect the smallest of those eight bits,
- 5:12but it effects the other 24
- 5:14of the 32-bit floating point representation,
- 5:17and that little tiny change is enough
- 5:19to fool the convolutional network
- 5:21into recognizing this image of a panda as being a gibbon.
- 5:26Another interesting thing is that
- 5:28it doesn't just change the class.
- 5:29It's not that we just barely found the decision boundary
- 5:32and just barely stepped across it.
- 5:34The convolutional network actually has much more confidence
- 5:37in its incorrect prediction,
- 5:40that the image on the right is a gibbon,
- 5:42than it had for the original being a panda.
- 5:45On the right, it believes that the image
- 5:47is a gibbon with 99.9% probability,
- 5:50so before it thought that there was about
- 5:531/3 chance that it was something other than a panda,
- 5:57and now it's about as certain as it can possibly be
- 6:00that it's a gibbon.
- 6:02As a little bit of history, people have studied ways
- 6:05of computing attacks to fool
- 6:07different machine learning models
- 6:09since at least about 2004, and maybe earlier.
- 6:13For a long time this was done in the context
- 6:15of fooling spam detectors.
- 6:17In about 2013, Battista Biggio found
- 6:21that you could fool neural networks in this way,
- 6:24and around the same time my colleague, Christian Szegedy,
- 6:27found that you could make this kind of attack
- 6:29against deep neural networks
- 6:30just by using an optimization algorithm
- 6:33to search on the input of the image.
- 6:36A lot of what I'll be telling you about today
- 6:37is my own follow-up work on this topic,
- 6:40but I've spent a lot of my career over the past few years
- 6:43understanding why these attacks are possible
- 6:46and why it's so easy to fool these convolutional networks.
- 6:52When my colleague, Christian,
- 6:54first discovered this phenomenon
- 6:57independently from Battista Biggio but around the same time,
- 7:01he found that it was actually a result
- 7:05of a visualization he was trying to make.
- 7:08He wasn't studying security.
- 7:10He wasn't studying how to fool a neural network.
- 7:12Instead, he had a convolutional network
- 7:14that could recognize objects very well,
- 7:16and he wants to understand how it worked,
- 7:19so he thought that maybe he could take an image of a scene,
- 7:24for example a picture of a ship,
- 7:26and he could gradually transform that image
- 7:28into something that the network would recognize
- 7:31as being an airplane.
- 7:33Over the course of that transformation,
- 7:35he could see how the features of the input change.
- 7:38You might expect that maybe the background 167 00:07:34,360 --> 00:07:37,692 would turn blue to look like the sky behind an airplane,
- 7:44or you might expect that the ship
- 7:46would grow wings to look more like an airplane.
- 7:48You could conclude from that that the convolution
- 7:51uses the blue sky or uses the wings to recognize airplanes.
- 7:56That's actually not really what happened at all.
- 7:59Each of these panels here shows an animation
- 8:01that you read left to right, top to bottom.
- 8:03Each panel is another step of gradient ascent
- 8:06on the log probability that the input is an airplane
- 8:11according to a convolutional net model,
- 8:14and then we follow the gradient on the input to the image.
- 8:18You're probably used to following the gradient
- 8:20on the parameters of a model.
- 8:22You can use the back propagation algorithm
- 8:23to compute the gradient on the input image
- 8:26using exactly the same procedure
- 8:28that you would use to compute the gradient
- 8:29on the parameters.
- 8:31In this animation of the ship in the upper left,
- 8:34we see five panels that all look basically the same.
- 8:37Gradient descent doesn't seem
- 8:39to have moved the image at all,
- 8:40but by the last panel the network is completely confident
- 8:43that this is an airplane.
- 8:45When you first code up this kind of experiment,
- 8:47especially if you don't know what's going to happen,
- 8:49it feels a little bit like you have a bug in your script
- 8:51and you're just displaying
- 8:52the same image over and over again.
- 8:54The first time I did it,
- 8:55I couldn't believe it was happening,
- 8:58and I had to open up the images in NumPy,
- 9:00and take the difference of them,
- 9:02and make sure that there was actually
- 9:03a non-zero difference in there, but there is.
- 9:07I show several different animations here
- 9:09of a ship, a car, a cat, and a truck.
- 9:13The only one where I actually see any change at all
- 9:15is the image of the cat.
- 9:18The color of the cat's face changes a little bit,
- 9:21and maybe it becomes a little bit more
- 9:23like the color of a metal airplane.
- 9:25Other than that, I don't see any changes
- 9:28in any of these animations,
- 9:29and I don't see anything very suggestive of an airplane.
- 9:33So gradient descent, rather than turning the input
- 9:36into an example of an airplane,
- 9:39has found an image that fools the network
- 9:42into thinking that the input is an airplane.
- 9:45And if we were malicious attackers
- 9:47we didn't even have to work very hard to figure out
- 9:49how to fool the network.
- 9:51We just asked the network
- 9:52to give us an image of an airplane,
- 9:53and it gave us something that fools it into thinking
- 9:56that the input is an airplane.
- 10:00When Christian first published this work,
- 10:02a lot of articles came out with titles like,
- 10:05The Flaw Looking At Every Deep Neural Network,
- 10:07or Deep Learning has Deep Flaws.
- 10:10It's important to remember that these vulnerabilities
- 10:12apply to essentially every machine learning algorithm
- 10:15that we've studied so far.
- 10:18Some of them like RBF networks
- 10:20and partisan density estimators
- 10:22are able to resist this effect somewhat,
- 10:24but even very simple machine learning algorithms
- 10:27are highly vulnerable to adversarial examples.
- 10:32In this image, I show an animation
- 10:33of what happens when we attack a linear model,
- 10:37so it's not a deep algorithm at all.
- 10:38It's just a shallow softmax model.
- 10:41You multiply by a matrix, you add a vector of bias terms,
- 10:45you apply the softmax function,
- 10:47and you've got your probability distribution
- 10:48over the 10 MNIST classes.
- 10:51At the upper left, I start with an image of a nine,
- 10:54and then as we move left to right, top to bottom,
- 10:57I gradually transform it to be a zero.
- 11:00Where I've drawn the yellow box,
- 11:02the model assigns high probability to it being a zero.
- 11:05I forget exactly what my threshold was for high probability,
- 11:08but I think it was around 0.9 or so.
- 11:11Then as we move to the second row,
- 11:13I transform it into a one,
- 11:15and the second yellow box indicates
- 11:17where we've successfully fooled the model
- 11:18into thinking it's a one with high probability.
- 11:21And then as you read the rest of the yellow boxes
- 11:23left to right, top to bottom,
- 11:25we go through the twos, threes, fours, and so on,
- 11:27until finally at the lower right
- 11:29we have a nine that has a yellow box around it,
- 11:31and it actually looks like a nine,
- 11:33but in this case the only reason
- 11:35it actually looks like a nine
- 11:36is that we started the whole process with a nine.
- 11:39We successfully swept through all 10 classes of MNIST
- 11:43without substantially changing the image of the digit
- 11:46in any way that would interfere with human recognition.
- 11:50This linear model was actually extremely easy to fool.
- 11:55Besides linear models, we've also seen
- 11:57that we can fool many different kinds of linear models
- 12:01including logistic regression and SVMs.
- 12:04We've also found that we can fool decision trees,
- 12:07and to a lesser extent, nearest neighbors classifiers.
- 12:13We wanted to explain exactly why this happens.
- 12:16Back in about 2014, after we'd published the original paper
- 12:20where we'd said that these problems exist,
- 12:22we were trying to figure out why they happen.
- 12:25When we wrote our first paper,
- 12:27we thought that basically this is a form of overfitting,
- 12:30that you have a very complicated deep neural network,
- 12:34it learns to fit the training set,
- 12:36its behavior on the test set is somewhat undefined,
- 12:39and then it makes random mistakes
- 12:41that an attacker can exploit.
- 12:44Let's walk through what that story looks like
- 12:45somewhat concretely.
- 12:47I have here a training set of three blue X's
- 12:50and three green O's.
- 12:53We want to make a classifier
- 12:54that can recognize X's and recognize O's.
- 12:57We have a very complicated classifier
- 12:59that can easily fit the training set,
- 13:01so we represent everywhere it believes
- 13:03X's should be with blobs of blue color,
- 13:06and I've drawn a blob of blue
- 13:08around all of the training set X's,
- 13:10so it correctly classifies the training set.
- 13:13It also has a blob of green mass showing where the O's are,
- 13:17and it successfully fits all of the green training set O's,
- 13:21but then because this is a very complicated function
- 13:24and it has just way more parameters
- 13:26than it actually needs to represent the training task,
- 13:30it throws little blobs of probability mass
- 13:33around the rest of space randomly.
- 13:35On the left there's a blob of green space
- 13:37that's kind of near the training set X's,
- 13:40and I've drawn a red X there to show
- 13:42that maybe this would be an adversarial example
- 13:43where we expect the classification to be X,
- 13:46but the model assigns O.
- 13:48On the right, I've shown that there's a red O
- 13:51where we have another adversarial example.
- 13:53We're very near the other O's.
- 13:55We might expect the model to assign this class to be an O,
- 13:58and yet because it's drawn blue mass there
- 14:00it's actually assigning it to be an X.
- 14:04If overfitting is really the story
- 14:05then each adversarial example is more or less
- 14:09the result of bad luck and also more or less unique.
- 14:12If we fit the model again
- 14:14or we fit a slightly different model
- 14:16we would expect to make different random mistakes
- 14:19on this points that are off the training set,
- 14:22but that was actually not what we found at all.
- 14:25We found that many different models would misclassify
- 14:28the same adversarial examples,
- 14:30and they would assign the same class to them.
- 14:33We also found that if we took the difference
- 14:36between an original example and an adversarial example
- 14:40then we had a direction in input space
- 14:43and we could add that same offset vector
- 14:46to any clean example, and we would almost always
- 14:49get an adversarial example as a result.
- 14:52So we started to realize
- 14:52that there was systematic effect going on here,
- 14:55not just a random effect.
- 14:57That led us to another idea
- 14:59which is that adversarial examples
- 15:01might actually be more like underfitting
- 15:03rather than overfitting.
- 15:05They might actually come from the model being too linear.
- 15:09Here I draw the same task again
- 15:11where we have the same manifold of O's
- 15:13and the same line of X's,
- 15:15and this time I fit a linear model to the data set
- 15:19rather than fitting a high capacity, non-linear model to it.
- 15:23We see that we get a dividing hyperplane
- 15:26running in between the two classes.
- 15:29This hyperplane doesn't really capture
- 15:30the true structure of the classes.
- 15:33The O's are clearly arranged in a C-shaped manifold.
- 15:37If we keep walking past the end of the O's,
- 15:40we've crossed the decision boundary and we've drawn a red O
- 15:43where even though we're very near the decision boundary
- 15:46and near other O's we believe that it is now an X.
- 15:49Similarly we can take steps that go from near X's
- 15:53to just over the line that are classified as O's.
- 15:57Another thing that's somewhat unusual about this plot
- 15:59is that if we look at the lower left or upper right corners
- 16:03these corners are very confidently classified
- 16:05as being X's on the lower left or O's on the upper right
- 16:09even though we've never seen any data over there at all.
- 16:12The linear model family forces the model
- 16:14to have very high confidence in these regions
- 16:17that are very far from the decision boundary.
- 16:22We've seen that linear models can actually assign
- 16:25really unusual confidence as you move very far
- 16:28from the decision boundary,
- 16:30even if there isn't any data there,
- 16:31but are deep neural networks actually
- 16:34anything like linear models?
- 16:36Could linear models actually explain anything
- 16:38about how it is that deep neural nets fail?
- 16:41It turns out that modern deep neural nets
- 16:43are actually very piecewise linear,
- 16:45so rather than being a single linear function
- 16:47they are piecewise linear
- 16:49with maybe not that many linear pieces.
- 16:53If we use rectified linear units
- 16:55then the mapping from the input image to the output logits
- 17:00is literally a piecewise linear function.
- 17:03By the logits I mean the un-normalized log probabilities
- 17:06before we apply the softmax op at the output of the model.
- 17:11There are other neural networks
- 17:13like maxout networks that are also
- 17:14literally piecewise linear.
- 17:17And then there are several that become very close to it.
- 17:19Before rectified linear units became popular
- 17:22most people used to use sigmoid units of one form or another
- 17:27either logistic sigmoid or hyperbolic tangent units.
- 17:30These sigmoidal units have to be carefully tuned,
- 17:33especially at initialization
- 17:35so that you spend most of your time
- 17:37near the center of the sigmoid
- 17:40where the sigmoid is approximately linear.
- 17:43Then finally, the LSTM, a kind of recurrent network
- 17:46that is one of the most popular recurrent networks today,
- 17:49uses addition from one time step to the next
- 17:52in order to accumulate and remember information over time.
- 17:56Addition is a particularly simple form of linearity,
- 18:00so we can see that the interaction
- 18:01from a very distant time step in the past and the present
- 18:06is highly linear within an LSTM.
- 18:09Now to be clear, I'm speaking about the mapping
- 18:11from the input of the model to the output of the model.
- 18:14That's what I'm saying is close to being linear
- 18:17or is piecewise linear with relatively few pieces.
- 18:21The mapping from the parameters of the network
- 18:23to the output of the network is non-linear
- 18:26because the weight matrices at each layer of the network
- 18:29are multiplied together.
- 18:31So we actually get extremely non-linear reactions
- 18:34between parameters and the output.
- 18:36That's what makes training a neural network so difficult.
- 18:39But the mapping from the input to the output
- 18:42is much more linear and predictable,
- 18:45and it means that optimization problems
- 18:47that aim to optimize the input to the model
- 18:50are much easier than optimization problems
- 18:53that aim to optimize the parameters.
- 18:57If we go and look for this happening in practice
- 18:59we can take a convolutional network
- 19:01and trace out a one-dimensional path
- 19:04through its input space.
- 19:07So what we're doing here is we're choosing a clean example.
- 19:09It's an image of a white car on a red background,
- 19:12and we are choosing a direction
- 19:14that will travel through space.
- 19:16We are going to have a coefficient epsilon
- 19:19that we multiply by this direction.
- 19:21When epsilon is negative 30,
- 19:22like at the left end of the plot,
- 19:24we're subtracting off a lot of this unit vector direction.
- 19:28When epsilon is zero, like in the middle of the plot,
- 19:30we're visiting the original image from the data set,
- 19:33and when epsilon is positive 30,
- 19:36like at the right end of the plot,
- 19:37we're adding this direction onto the input.
- 19:42In the panel on the left, I show you an animation
- 19:45where we move from epsilon equals negative 30
- 19:47as up to epsilon equals positive 30.
- 19:50You read the animation left to right, top to bottom,
- 19:53and everywhere that there's a yellow box
- 19:56the input has correctly recognized as being a car.
- 20:01On the upper left, you see that it looks mostly blue.
- 20:04On the lower right, it's hard to tell what's going on.
- 20:07It's kind of reddish and so on.
- 20:10In the middle row, just after where the yellow boxes end
- 20:13you can see pretty clearly
- 20:14that it's a car on a red background,
- 20:17though the image is small on these slides.
- 20:20What's interesting to look at here is the logits
- 20:23that the model outputs.
- 20:25This is a deep convolutional rectified linear unit network.
- 20:30Because it uses rectified linear units,
- 20:32we know that the output is a piecewise linear function
- 20:36of the input to the model.
- 20:38The main question we're asking by making this plot
- 20:40is how many different pieces
- 20:42does this piecewise linear function have
- 20:45if we look at one particular cross section.
- 20:48You might think that maybe a deep net
- 20:50is going to represent some extremely
- 20:52wiggly complicated function with lots and lots
- 20:54of linear pieces no matter which cross section you look in.
- 20:58Or we might find that it has more or less two pieces
- 21:01for each function we look at.
- 21:04Each of the different curves on this plot
- 21:07is the logits for a different class.
- 21:10We see that out at the tails of the plot
- 21:13that the frog class is the most likely,
- 21:16and the frog class basically looks like
- 21:18a big v-shaped function.
- 21:21The logits for the frog class become very high
- 21:24when epsilon is negative 30 or positive 30,
- 21:27and they drop down and become a little bit negative
- 21:29when epsilon is zero.
- 21:32The car class, listed as automobile here,
- 21:37it's actually high in the middle,
- 21:39and the car is correctly recognized.
- 21:42As we sweep out to very negative epsilon,
- 21:44the logits for the car class do increase,
- 21:47but they don't increase nearly as quickly
- 21:49as the logits for the frog class.
- 21:51So, we've found a direction
- 21:52that's associated with the frog class
- 21:54and as we follow it out to a relatively large perturbation,
- 21:59we find that the model extrapolates linearly
- 22:02and begins to make a very unreasonable prediction
- 22:04that the frog class is extremely likely
- 22:07just because we've moved for a long time
- 22:09in this direction that was locally associated
- 22:12with the frog class being more likely.
- 22:17When we actually go and construct adversarial examples,
- 22:20we need to remember that we're able to get
- 22:23quite a large perturbation
- 22:24without changing the image very much
- 22:26as far as a human being is concerned.
- 22:30So here I show you a handwritten digit three,
- 22:33and I'm going to change it in several different ways,
- 22:36and all of these changes have
- 22:37the same L2 norm perturbation.
- 22:40In the top row, I'm going to change the three into a seven
- 22:44just by looking for the nearest seven in the training set.
- 22:47The difference between those two
- 22:49is this image that looks a little bit like the seven
- 22:53wrapped in some black lines.
- 22:55So here white pixels in the middle image
- 22:57in the perturbation column,
- 22:59the white pixels represent adding something
- 23:02and black pixels represent subtracting something
- 23:04as you move from the left column to the right column.
- 23:08So when we take the three and we apply this perturbation
- 23:11that transforms it into a seven,
- 23:13we can measure the L2 norm of that perturbation.
- 23:16And it turns out to have an L2 norm of 3.96.
- 23:20That gives you kind of a reference
- 23:21for how big these perturbations can be.
- 23:24In the middle row, we apply a perturbation
- 23:26of exactly the same size,
- 23:28but with the direction chosen randomly.
- 23:30In this case we don't actually change
- 23:32the class of the three at all,
- 23:33we just get some random noise
- 23:35that didn't really change the class.
- 23:37A human could still easily read it as being a three.
- 23:41And then finally at the very bottom row,
- 23:44we take the three and we just erase a piece of it
- 23:46with a perturbation of the same norm
- 23:48and we turn it into something
- 23:50that doesn't have any class at all.
- 23:52It's not a three, it's not a seven,
- 23:53it's just a defective input.
- 23:56All of these changes can happen
- 23:57with the same L2 norm perturbation.
- 24:00And actually a lot of the time with adversarial examples,
- 24:03you make perturbations that have an even larger L2 norm.
- 24:06What's going on is that
- 24:07there are several different pixels in the image,
- 24:09and so small changes to individual pixels
- 24:12can add up to relatively large vectors.
- 24:15For larger datasets like ImageNet,
- 24:17where there's even more pixels,
- 24:18you can make very small changes to each pixel
- 24:21that travel very far in vector space
- 24:24as measured by the L2 norm.
- 24:26That means that you can actually make changes
- 24:28that are almost imperceptible
- 24:30but actually move you really far
- 24:31and get a large dot product
- 24:33with the coefficients of the linear function
- 24:36that the model represents.
- 24:38It also means that when
- 24:39we're constructing adversarial examples,
- 24:41we need to make sure that the adversarial example procedure
- 24:44isn't able to do what happened
- 24:46in the top row of this slide here.
- 24:48So in the top row of this slide,
- 24:49we took the three and we actually
- 24:50just changed it into a seven.
- 24:52So when the model says that the image
- 24:53in the upper right is a seven, it's not a mistake.
- 24:56We actually just changed the input class.
- 24:59When we build adversarial examples,
- 25:00we want to make sure that we're measuring real mistakes.
- 25:02If we're experimenters studying
- 25:04how easy a network is to fool,
- 25:06we want to make sure that we're actually fooling it
- 25:08and not just changing the input class.
- 25:11And if we're an attacker, we actually want to make sure
- 25:13that we're causing misbehavior in the system.
- 25:17To do that, when we build adversarial examples,
- 25:19we use the maxnorm to constrain the perturbation.
- 25:24Basically this says that no pixel can change
- 25:26by more than some amount epsilon.
- 25:28So the L2 norm can get really big,
- 25:30but you can't concentrate all the changes
- 25:33for that L2 norm to erase pieces of the digit,
- 25:35like in the bottom row here we erased the top of a three.
- 25:39One very fast way to build an adversarial example
- 25:42is just to take the gradient of the cost
- 25:45that you used to train the network
- 25:47with respect to the input,
- 25:48and then take the sign of that gradient.
- 25:51The sign is essentially enforcing the maxnorm constraint.
- 25:55You're only allowed to change the input by
- 25:58up to epsilon at each pixel,
- 26:00so if you just take the sign it tells you
- 26:02whether you want to add epsilon or subtract epsilon
- 26:04in order to hurt the network.
- 26:07You can view this as taking the observation
- 26:08that the network is more or less linear,
- 26:10as we showed on this slide,
- 26:12and using that to motivate
- 26:14building a first order Taylor series approximation
- 26:17of the neural network's cost.
- 26:21And then subject to that Taylor series approximation,
- 26:24we want to maximize the cost
- 26:26following this maxnorm constraint.
- 26:28And that gives us this technique that we call
- 26:30the fast gradient sign method.
- 26:32If you want to just get your hands dirty
- 26:34and start making adversarial examples really quickly,
- 26:36or if you have an algorithm where you want to train
- 26:38on adversarial examples in the inner loop of learning,
- 26:41this method will make adversarial examples for you
- 26:43very, very quickly.
- 26:45In practice you should also use other methods,
- 26:47like Nicholas Carlini's attack based on
- 26:50multiple steps of the Adam optimizer,
- 26:52to make sure that you have a very strong attack
- 26:55that you bring out when you think you have a model
- 26:57that might be more powerful.
- 26:59A lot of the time people find that they can defeat
- 27:02the fast gradient sign method
- 27:03and think that they've built a successful defense,
- 27:05but then when you bring out a more powerful method
- 27:08that takes longer to evaluate,
- 27:10they find that they can't overcome
- 27:12the more computationally expensive attack.
- 27:18I've told you that adversarial examples happen
- 27:20because the model is very linear.
- 27:22And then I told you that we could
- 27:23use this linearity assumption
- 27:25to build this attack, the fast gradient sign method.
- 27:28This method, when applied to a regular neural network
- 27:31that doesn't have any special defenses,
- 27:34will get over a 99% attack success rate.
- 27:38So that seems to confirm, somewhat,
- 27:40this hypothesis that adversarial examples
- 27:42come from the model being far too linear
- 27:45and extrapolating in linear fashions when it shouldn't.
- 27:48Well we can actually go looking for some more evidence.
- 27:51My friend David Warde-Farley and I built these maps
- 27:54of the decision boundaries of neural networks.
- 27:57And we found that they are consistent
- 27:58with the linearity hypothesis.
- 28:02So the FGSM is that attack method
- 28:04that I described in the previous slide,
- 28:06where we take the sign of the gradient.
- 28:08We'd like to build a map
- 28:09of a two-dimensional cross section of input space
- 28:13and show which classes are assigned
- 28:15to the data at each point.
- 28:18In the grid on the right, each different cell,
- 28:21each little square within the grid,
- 28:23is a map of a CIFAR-10 classifier's decision boundary,
- 28:27with each cell corresponding to a different
- 28:29CIFAR-10 testing sample.
- 28:32On the left I show you a little legend
- 28:34where you can understand what each cell means.
- 28:37The very center of each cell corresponds to
- 28:40the original example from the CIFAR-10 dataset
- 28:43with no modification.
- 28:45As we move left to right in the cell,
- 28:47we're moving in the direction
- 28:48of the fast gradient sign method attack.
- 28:50So just the sign of the gradient.
- 28:53As we move up and down within the cell,
- 28:54we're moving in a random direction that's orthogonal to
- 28:58the fast gradient sign method direction.
- 29:00So we get to see a cross section, a 2D cross section
- 29:04of CIFAR-10 decision space.
- 29:07At each pixel within this map,
- 29:09we plot a color that tells us which class is assigned there.
- 29:13We use white pixels to indicate that
- 29:15the correct class was chosen,
- 29:17and then we used different colors to represent
- 29:19all of the other incorrect classes.
- 29:21You can see that in nearly all
- 29:23of the grid cells on the right,
- 29:25roughly the left half of the image is white.
- 29:29So roughly the left half of the image
- 29:31has been correctly classified.
- 29:33As we move to the right, we see that there is usually
- 29:36a different color on the right half.
- 29:39And the boundaries between these regions
- 29:41are approximately linear.
- 29:43What's going on here is that the fast gradient sign method
- 29:45has identified a direction
- 29:47where if we get a large dot product with that direction
- 29:50we can get an adversarial example.
- 29:52And from this we can see that adversarial examples
- 29:54live more or less in linear subspaces.
- 29:59When we first discovered adversarial examples,
- 30:01we thought that they might live in little tiny pockets.
- 30:04In the first paper we actually speculated that
- 30:06maybe they're a little bit like the rational numbers,
- 30:09hiding out finely tiled among the real numbers,
- 30:11with nearly every real number being near a rational number.
- 30:15We thought that because we were able to find
- 30:17an adversarial example corresponding
- 30:18to every clean example that we loaded into the network.
- 30:22After doing this further analysis,
- 30:23we found that what's happening is that every real example
- 30:27is near one of these linear decision boundaries
- 30:29where you cross over into an adversarial subspace.
- 30:32And once you're in that adversarial subspace,
- 30:35all the other points nearby are also adversarial examples
- 30:38that will be misclassified.
- 30:40This has security implications
- 30:42because it means you only need to get the direction right.
- 30:46You don't need to find an exact coordinate in space.
- 30:48You just need to find a direction
- 30:50that has a large dot product with the sign of the gradient.
- 30:54And once you move more or less approximately
- 30:56in that direction, you can fool the model.
- 31:01We also made another cross section
- 31:02where after using the left-right axis
- 31:05as the fast gradient sign method,
- 31:07we looked for a second direction
- 31:09that has high dot product with the gradient
- 31:11so we could make both axes adversarial.
- 31:14And in this case you see that we get
- 31:16linear decision boundaries.
- 31:18They're now oriented diagonally rather than vertically,
- 31:21but you can see that there's actually
- 31:23this two-dimensional subspace
- 31:24of adversarial examples that we can cross into.
- 31:29Finally it's important to remember
- 31:30that adversarial examples are not noise.
- 31:33You can add a lot of noise to an adversarial example
- 31:35and it will stay adversarial.
- 31:37You can add a lot of noise to a clean example
- 31:39and it will stay clean.
- 31:40Here we make random cross sections
- 31:42where both axes are randomly chosen directions.
- 31:45And you see that on CIFAR-10,
- 31:47most of the cells are completely white,
- 31:49meaning that they're correctly classified to start with,
- 31:51and when you add noise they stay correctly classified.
- 31:54We also see that the model makes some mistakes
- 31:56because this is the test set.
- 31:58And generally if a test example starts out misclassified,
- 32:01adding the noise doesn't change it.
- 32:03There are a few exceptions where,
- 32:05if you look in the third row, third column,
- 32:08noise actually can make the model misclassify the example
- 32:12for especially large noise values.
- 32:14And there's even some where,
- 32:17in the top row there's one example you can see where
- 32:20the model is misclassifying the test example to start with
- 32:23but then noise can change it to be correctly classified.
- 32:26For the most part, noise has very little effect
- 32:28on the classification decision
- 32:31compared to adversarial examples.
- 32:33What's going on here is that in high dimensional spaces,
- 32:36if you choose some reference vector
- 32:38and then you choose a random vector
- 32:41in that high dimensional space,
- 32:42the random vector will, on average,
- 32:45have zero dot product with the reference vector.
- 32:49So if you think about making
- 32:51a first order Taylor series approximation of your cost,
- 32:54and thinking about how your Taylor series approximation
- 32:57predicts that random vectors will change your cost.
- 33:00You see that random vectors on average
- 33:02have no effect on the cost.
- 33:04But adversarial examples are chosen to maximize it.
- 33:10In these plots we looked in two dimensions.
- 33:13More recently, Florian Tramer here at Stanford
- 33:16got interested in finding out
- 33:17just how many dimensions there are to these subspaces
- 33:20where the adversarial examples
- 33:22lie in a thick contiguous region.
- 33:25And we came up with an algorithm together
- 33:28where you actually look for
- 33:30several different orthogonal vectors
- 33:32that all have a large dot product with the gradient.
- 33:35By looking in several different
- 33:38orthogonal directions simultaneously,
- 33:40we can map out this kind of polytope
- 33:42where many different adversarial examples live.
- 33:45We found out that this adversarial region
- 33:47has on average about 25 dimensions.
- 33:51If you look at different examples you'll find
- 33:53different numbers of adversarial dimensions.
- 33:56But on average on MNIST we found it was about 25.
- 33:59So what's interesting here is the dimensionality
- 34:02actually tells you something about
- 34:04how likely you are to find an adversarial example
- 34:06by generating random noise.
- 34:09If every direction were adversarial,
- 34:12then any change would cause a misclassification.
- 34:15If most of the directions were adversarial,
- 34:17then random directions would end up being adversarial
- 34:20just by accident most of the time.
- 34:22And then if there was only one adversarial direction,
- 34:25you'd almost never find that direction
- 34:28just by adding random noise.
- 34:30When there's 25 you have a chance of doing it sometimes.
- 34:34Another interesting thing is that different models
- 34:36will often misclassify the same adversarial examples.
- 34:39The subspace dimensionality of the adversarial subspace
- 34:43relates to that transfer property.
- 34:46The larger the dimensionality of the subspace,
- 34:48the more likely it is that the subspaces
- 34:50for two models will intersect.
- 34:52So if you have two different models
- 34:55that have a very large adversarial subspace,
- 34:57you know that you can probably transfer
- 34:58adversarial examples from one to the other.
- 35:01But if the adversarial subspace is very small,
- 35:03then unless there's some kind of really systematic effect
- 35:06forcing them to share exactly the same subspace,
- 35:09it seems less likely that you'll be able to transfer
- 35:11examples just due to the subspaces randomly aligning.
- 35:17A lot of the time in the adversarial example
- 35:20research community,
- 35:21we refer back to the story of Clever Hans.
- 35:25This comes from an essay by Bob Sturm called
- 35:28Clever Hans, Clever Algorithms.
- 35:30Because Clever Hans is a pretty good metaphor
- 35:32for what's happening with machine learning algorithms.
- 35:35So Clever Hans was a horse that lived in the early 1900s.
- 35:39His owner trained him to do arithmetic problems.
- 35:43So you could ask him, "Clever Hans,
- 35:45"what's two plus one?"
- 35:47And he would answer by tapping his hoof.
- 35:52And after the third tap, everybody would start
- 35:54cheering and clapping and looking excited
- 35:56because he'd actually done an arithmetic problem.
- 35:59Well it turned out that
- 36:01he hadn't actually learned to do arithmetic.
- 36:03But it was actually pretty hard to figure out
- 36:05what was going on.
- 36:06His owner was not trying to defraud anybody,
- 36:10his owner actually believed he could do arithmetic.
- 36:13And presumably Clever Hans himself
- 36:15was not trying to trick anybody.
- 36:18But eventually a psychologist examined him
- 36:20and found that if he was put in a room alone
- 36:23without an audience,
- 36:25and the person asking the questions wore a mask,
- 36:29he couldn't figure out when to stop tapping.
- 36:31You'd ask him, "Clever Hans,
- 36:32"what's one plus one?"
- 36:33And he'd just [knocking]
- 36:38keep staring at your face, waiting for you
- 36:40to give him some sign that he was done tapping.
- 36:42So everybody in this situation
- 36:44was trying to do the right thing.
- 36:46Clever Hans was trying to do whatever it took
- 36:48to get the apple that his owner would give him
- 36:51when he answered an arithmetic problem.
- 36:53His owner did his best to train him correctly
- 36:56with real arithmetic questions
- 36:57and real rewards for correct answers.
- 37:00And what happened was that Clever Hans
- 37:03inadvertently focused on the wrong cue.
- 37:07He found this cue of people's social reactions
- 37:09that could reliably help him solve the problem,
- 37:12but then it didn't generalize to a test set
- 37:15where you intentionally took that cue away.
- 37:18It did generalize to a naturally occurring test set,
- 37:21where he had an audience.
- 37:22So that's more or less what's happening
- 37:24with machine learning algorithms.
- 37:26They've found these very linear patterns
- 37:28that can fit the training data,
- 37:30and these linear patterns even generalize to the test data.
- 37:34They've learned to handle any example that comes from
- 37:36the same distribution as their training data.
- 37:40But then if you shift the distribution
- 37:42that you test them on,
- 37:43if a malicious adversary actually creates examples
- 37:46that are intended to fool them,
- 37:48they're very easily fooled.
- 37:51In fact we find that modern machine learning algorithms
- 37:54are wrong almost everywhere.
- 37:56We tend to think of them as being correct most of the time,
- 37:59because when we run them on naturally occurring inputs
- 38:02they achieve very high accuracy percentages.
- 38:06But if we look instead of as the percentage
- 38:08of samples from an IID test set,
- 38:12if we look at the percentage of the space in RN
- 38:15that is correctly classified,
- 38:17we find that they misclassify almost everything
- 38:20and they behave reasonably only on a very thin manifold
- 38:24surrounding the data that we train them on.
- 38:27In this plot, I show you several different examples
- 38:30of Gaussian noise
- 38:32that I've run through a CIFAR-10 classifier.
- 38:35Everywhere that there is a pink box,
- 38:37the classifier thinks that there is something
- 38:39rather than nothing.
- 38:40I'll come back to what that means in a second.
- 38:43Everywhere that there is a yellow box,
- 38:45one step of the fast gradient sign method
- 38:47was able to persuade the model that it was looking
- 38:50specifically at an airplane.
- 38:52I chose the airplane class
- 38:53because it was the one with the lowest success rate.
- 38:56It had about a 25% success rate.
- 38:58That means an attacker would need four chances
- 39:01to get noise recognized as an airplane on this model.
- 39:06An interesting thing, and appropriate enough
- 39:08given the story of Clever Hans,
- 39:09is that this model found that about 70% of RN
- 39:12was classified as a horse.
- 39:17So I mentioned that this model will say
- 39:20that noise is something rather than nothing.
- 39:22And it's actually kind of important to think about
- 39:24how we evaluate that.
- 39:26If you have a softmax classifier,
- 39:28it has to give you a distribution
- 39:30over the n different classes that you train it on.
- 39:34So there's a few ways that you can argue
- 39:35that the model is telling you
- 39:37that there's something rather than nothing.
- 39:39One is you can say, if it assigns something like 90%
- 39:42to one particular class,
- 39:43that seems to be voting for that class being there.
- 39:46We'd much rather see it give us
- 39:47something like a uniform distribution saying
- 39:50this noise doesn't look like anything in the training set
- 39:52so it's equally likely to be a horse or a car.
- 39:56And that's not what the model does.
- 39:58It'll say, this is very definitely a horse.
- 40:01Another thing that you can do is you can replace
- 40:03the last layer of the model.
- 40:05For example, you can use a sigmoid output for each class.
- 40:10And then the model is actually capable of telling you
- 40:11that any subset of classes is present.
- 40:14It could actually tell you that an image
- 40:15is both a horse and a car.
- 40:17And what we would like it to do for the noise
- 40:19is tell us that none of the classes is present,
- 40:21that all of the sigmoids should have a value
- 40:23of less than 1/2.
- 40:25And 1/2 isn't even particularly a low threshold.
- 40:29We could reasonably expect that all of the sigmoids would be
- 40:32less than 0.01 for such a defective input as this.
- 40:35But what we find instead is that the sigmoids
- 40:38tend to have at least one class present
- 40:40just when we run Gaussian noise
- 40:42of sufficient norm through the model.
- 40:48We've also found that we can do adversarial examples
- 40:50for reinforcement learning.
- 40:51And there's a video for this.
- 40:53I'll upload the slides after the talk
- 40:54and you can follow the link.
- 40:56Unfortunately I wasn't able to get the WiFi to work
- 40:58so I can't show you the video animated.
- 41:00But I can describe basically what's going on
- 41:01from this still here.
- 41:05There's a game Seaquest on Atari
- 41:08where you can train reinforcement learning agents
- 41:09to play that game.
- 41:11And you can take the raw input pixels
- 41:14and you can take the fast gradient sign method
- 41:18or other attacks that use other norms besides the max norm,
- 41:21and compute perturbations that are intended
- 41:24to change the action that the policy would select.
- 41:27So the reinforcement learning policy,
- 41:29you can think of it as just being like a classifier
- 41:31that looks at a frame.
- 41:33And instead of categorizing the input
- 41:35into a particular category,
- 41:37it gives you a softmax distribution over actions to take.
- 41:40So if we just take that and say that the most likely action
- 41:43should have its accuracy be decreased by the adversary.
- 41:47Sorry, to have its probability
- 41:49be decreased by the adversary,
- 41:51you'll get these perturbations of input frames
- 41:53that you can then apply and cause the agent
- 41:55to play different actions than it would have otherwise.
- 41:58And using this you can make the agent
- 42:00play Seaquest very, very badly.
- 42:03It's maybe not the most interesting possible thing.
- 42:06What we'd really like is an environment
- 42:07where there are many different reward functions available
- 42:09for us to study.
- 42:11So for example, if you had a robot
- 42:15that was intended to cook scrambled eggs,
- 42:17and you had a reward function measuring
- 42:18how well it's cooking scrambled eggs,
- 42:20and you had another reward function
- 42:22measuring how well it's cooking chocolate cake,
- 42:25it would be really interesting if we could make
- 42:27adversarial examples that cause the robot
- 42:29to make a chocolate cake
- 42:31when the user intended for it to make scrambled eggs.
- 42:35That's because it's very difficult to succeed at something
- 42:37and it's relatively straightforward to make a system fail.
- 42:40So right now, adversarial examples for RL
- 42:42are very good at showing that we can make RL agents fail.
- 42:45But we haven't yet been able to hijack them
- 42:47and make them do a complicated task
- 42:49that's different from what their owner intended.
- 42:51Seems like it's one of the next steps
- 42:53in adversarial example research though.
- 42:58If we look at high-dimension linear models,
- 43:01we can actually see that a lot of this
- 43:02is very simple and straightforward.
- 43:04Here we have a logistic regression model
- 43:07that classifies sevens and threes.
- 43:10So the whole model can be described just by a weight vector
- 43:13and a single scalar bias term.
- 43:16We don't really need to see the bias term for this exercise.
- 43:20If you look on the left I've plotted the weights
- 43:22that we used to discriminate sevens and threes.
- 43:24The weights should look a little bit like the difference
- 43:27between the average seven and the average three.
- 43:30And then down at the bottom we've taken
- 43:31the sign of the weights.
- 43:33So the gradient for a logistic regression model
- 43:35is going to be proportional to the weights.
- 43:38And then the sign of the weights gives you
- 43:41essentially the sign of the gradient.
- 43:43So we can do the fast gradient sign method
- 43:46to attack this model just by looking at its weights.
- 43:49In the examples in the panel
- 43:52that's the second column from the left
- 43:54we can see clean examples.
- 43:55And then on the right we've just added or subtracted
- 43:58this image of the sign of the weights off of them.
- 44:00To you and me as human observers,
- 44:03the sign of the weights is just like garbage
- 44:06that's in the background,
- 44:08and we more or less filter it out.
- 44:09It doesn't look particularly interesting to us.
- 44:11It doesn't grab our attention.
- 44:14To the logistic regression model
- 44:16this image of the sign of the weights
- 44:17is the most salient thing
- 44:20that could ever appear in the image.
- 44:22When it's positive it looks like
- 44:24the world's most quintessential seven.
- 44:26When it's negative it looks like
- 44:27the world's most quintessential three.
- 44:29And so the model makes its decision
- 44:31almost entirely based on this perturbation
- 44:33we added to the image, rather than on the background.
- 44:38You could also take this same procedure,
- 44:40and my colleague Andrej at OpenAI showed how you can
- 44:45modify the image on ImageNet using this same approach,
- 44:49and turn this goldfish into a daisy.
- 44:51Because ImageNet is much higher dimensional,
- 44:53you don't need to use quite as large of a coefficient
- 44:56on the image of the weights.
- 44:58So we can make a more persuasive fooling attack.
- 45:03You can see that this same image of the weights,
- 45:05when applied to any different input image,
- 45:08will actually reliably cause a misclassification.
- 45:12What's going on is that there are many different classes,
- 45:14and it means that if you choose the weights
- 45:18for any particular class,
- 45:20it's very unlikely that a new test image
- 45:23will belong to that class.
- 45:25So on ImageNet, if we're using
- 45:27the weights for the daisy class,
- 45:29and there are 1,000 different classes,
- 45:31then we have about a 99.9% chance
- 45:33that a test image will not be a daisy.
- 45:36If we then go ahead and add the weights
- 45:37for the daisy class to that image,
- 45:39then we get a daisy, and because that's not
- 45:41the correct class, it's a misclassification.
- 45:45So there's a paper at CVPR this year
- 45:47called Universal Adversarial Perturbations
- 45:48that expands a lot more on this observation
- 45:51that we had going back in 2014.
- 45:53But basically these weight vectors,
- 45:56when applied to many different images,
- 45:59can cause misclassification in all of them.
- 46:04I've spent a lot of time telling you
- 46:06that these linear models are just terrible,
- 46:08and at some point you've probably been hoping
- 46:11I would give you some sort of a control experiment
- 46:13to convince you that there's another model
- 46:15that's not terrible.
- 46:16So it turns out that some quadratic models
- 46:19actually perform really well.
- 46:21In particular a shallow RBF network
- 46:23is able to resist adversarial perturbations very well.
- 46:27Earlier I showed you an animation
- 46:29where I took a nine and I turned it into
- 46:30a zero, one, two, and so on,
- 46:32without really changing its appearance at all.
- 46:34And I was able to fool
- 46:36a linear softmax regression classifier.
- 46:39Here I've got an RBF network
- 46:40where it outputs a separate probability
- 46:43of each class being absent or present,
- 46:45and that probability is given by e to the negative square
- 46:51of the difference between a template image
- 46:53and the input image.
- 46:55And if we actually follow the gradient of this classifier,
- 46:59it does actually turn the image into
- 47:01a zero, a one, a two, a three, and so on,
- 47:04and we can actually recognize those changes.
- 47:07The problem is, this classifier does not get
- 47:09very good accuracy on the training set.
- 47:12It's a shallow model.
- 47:13It's basically just a template matcher.
- 47:15It is literally a template matcher.
- 47:17And if you try to make it more sophisticated
- 47:20by making it deeper,
- 47:22it turns out that the gradient of these RBF units is zero,
- 47:27or very near zero, throughout most of RN.
- 47:30So they're extremely difficult to train,
- 47:32even with batch normalization and methods like that.
- 47:36I haven't managed to train a deep RBF network yet.
- 47:39But I think if somebody comes up with better hyperparameters
- 47:42or a new, more powerful optimization algorithm,
- 47:46it might be possible to solve
- 47:47the adversarial example problem
- 47:49by training a deep RBF network
- 47:51where the model is so nonlinear and has such wide flat areas
- 47:55that the adversary is not able to push the cost uphill
- 47:59just by making small changes to the model's input.
- 48:05One of the things that's the most alarming
- 48:06about adversarial examples
- 48:08is that they generalize from one dataset to another
- 48:11and one model to another.
- 48:13Here I've trained two different models
- 48:15on two different training sets.
- 48:17The training sets are tiny in both cases.
- 48:20It's just MNIST three versus seven classification,
- 48:23and this is really just for the purpose of making a slide.
- 48:26If you train a logistic regression model
- 48:29on the digits shown in the left panel,
- 48:32you get the weights shown on the left in the lower panel.
- 48:35If you train a logistic regression model
- 48:37on the digits shown in the upper right,
- 48:39you get the weights shown on the right in the lower panel.
- 48:42So you've got two different training sets
- 48:44and we learn weight vectors that look
- 48:45very similar to each other.
- 48:47That's just because machine learning algorithms generalize.
- 48:50You want them to learn a function that's
- 48:51somewhat independent of the data that you train them on.
- 48:54It shouldn't matter which particular
- 48:55training examples you choose.
- 48:57If you want to generalize
- 48:58from the training set to the test set,
- 49:00you've also got to expect that different training sets
- 49:02will give you more or less the same result.
- 49:05And that means that because they've learned
- 49:06more or less similar functions,
- 49:08they're vulnerable to similar adversarial examples.
- 49:13An adversary can compute an image that fools one
- 49:15and use it to fool the other.
- 49:18In fact we can actually go ahead and measure
- 49:20the transfer rate between
- 49:22several different machine learning techniques,
- 49:24not just different data sets.
- 49:27Nicolas Papernot and his collaborators
- 49:28have spent a lot of time exploring
- 49:30this transferability effect.
- 49:32And they found that for example,
- 49:35logistic regression makes adversarial examples
- 49:38that transfer to decision trees with 87.4% probability.
- 49:44Wherever you see dark squares in this matrix,
- 49:48that shows that there's a high amount of transfer.
- 49:50That means that it's very possible for an attacker
- 49:53using the model on the left
- 49:56to create adversarial examples for the model on the right.
- 50:01The procedure overall is that,
- 50:03suppose the attacker wants to fool a model
- 50:05that they don't actually have access to.
- 50:07They don't know the architecture that's used
- 50:10to train the model.
- 50:11They may not even know which algorithm is being used.
- 50:13They may not know whether they're attacking
- 50:15a decision tree or a deep neural net.
- 50:17And they also don't know the parameters
- 50:20of the model that they're going to attack.
- 50:23So what they can do is train their own model
- 50:26that they'll use to build the attack.
- 50:30There's two different ways you can train your own model.
- 50:32One is you can label your own training set
- 50:33for the same task that you want to attack.
- 50:36Say that somebody is using an ImageNet classifier,
- 50:39and for whatever reason you don't have access to ImageNet,
- 50:42you can take your own photos and label them,
- 50:44train your own object recognizer.
- 50:46It's going to share adversarial examples
- 50:48with an ImageNet model.
- 50:50The other thing you can do is,
- 50:52say that you can't afford to gather your own training set.
- 50:55What you can do instead is if you can get
- 50:57limited access to the model
- 50:59where you just have the ability to send inputs to the model
- 51:02and observe its outputs,
- 51:03then you can send those inputs, observe the outputs,
- 51:06and use those as your training set.
- 51:09This'll work even if the output
- 51:11that you get from the target model
- 51:12is only the class label that it chooses.
- 51:15A lot of people read this and assume that
- 51:17you need to have access
- 51:19to all the probability values it outputs.
- 51:21But even just the class labels are sufficient.
- 51:24So once you've used one of these two methods,
- 51:26either gather your own training set
- 51:28or observing the outputs of a target model,
- 51:31you can train your own model
- 51:32and then make adversarial examples for your model.
- 51:36Those adversarial examples are very likely to transfer
- 51:38and affect the target model.
- 51:41So you can then go and send those out and fool it,
- 51:43even if you didn't have access to it directly.
- 51:48We've also measured the transferability
- 51:50across different data sets,
- 51:52and for most models we find that they're
- 51:54kind of in an intermediate zone
- 51:56where different data sets will result
- 51:58in a transfer rate of, like, 60% to 80%.
- 52:01There's a few models like SVMs that are very data dependent
- 52:04because SVMs end up focusing on a very small subset
- 52:08of the training data to form their final decision boundary.
- 52:10But most models that we care about
- 52:12are somewhere in the intermediate zone.
- 52:17Now that's just assuming that you rely
- 52:19on the transfer happening naturally.
- 52:22You make an adversarial example
- 52:23and you hope that it will transfer to your target.
- 52:26What if you do something to stack the deck in your favor
- 52:30and improve the odds that you'll get
- 52:33your adversarial examples to transfer?
- 52:35Dawn Song's group at UC Berkeley studied this.
- 52:38They found that if they take an ensemble of different models
- 52:43and they use gradient descent to search for
- 52:46an adversarial example that will fool
- 52:48every member of their ensemble,
- 52:50then it's extremely likely that it will transfer
- 52:53and fool a new machine learning model.
- 52:56So if you have an ensemble of five models,
- 52:59you can get it to the point where
- 53:00there's essentially a 100% chance
- 53:02that you'll fool a sixth model
- 53:04out of the set of models that they compared.
- 53:07They looked at things like ResNets of different depths,
- 53:09VGG, and GoogLeNet.
- 53:12So in the labels for each of the different rows
- 53:16you can see that they made ensembles that lacked
- 53:18each of these different models,
- 53:19and then they would test it on the different target models.
- 53:23So like if you make an ensemble that omits GoogLeNet,
- 53:28you have only about a 5% chance of GoogLeNet
- 53:32correctly classifying the adversarial example
- 53:34you make for that ensemble.
- 53:37If you make an ensemble that omits ResNet-152,
- 53:40in their experiments they found that
- 53:42there was a 0% chance of ResNet-152 resisting that attack.
- 53:48That probably indicates they should have run
- 53:50some more adversarial examples
- 53:52until they found a non-zero success rate,
- 53:54but it does show that the attack is very powerful.
- 53:57And then when you go look into
- 53:59intentionally cause the transfer effect,
- 54:01you can really make it quite strong.
- 54:05A lot of people often ask me if the human brain
- 54:08is vulnerable to adversarial examples.
- 54:10And for this lecture I can't use copyrighted material,
- 54:14but there's some really hilarious things on the Internet
- 54:17if you go looking for, like,
- 54:21the fake CAPTCHA with images of Mark Hamill,
- 54:23you'll find something that my perception system
- 54:27definitely can't handle.
- 54:29So here's another one that's actually published
- 54:31with a license where I was confident I'm allowed to use it.
- 54:35You can look at this image of different circles here,
- 54:38and they appear to be intertwined spirals.
- 54:42But in fact they are concentric circles.
- 54:45The orientation of the edges of the squares
- 54:47is interfering with the edge detectors in your brain,
- 54:51making it look like the circles are spiraling.
- 54:55So you can think of these optical illusions
- 54:57as being adversarial examples in the human brain.
- 54:59What's interesting is that we don't seem to share
- 55:01many adversarial examples in common
- 55:03with machine learning models.
- 55:05Adversarial examples transfer extremely reliably
- 55:08between different machine learning models,
- 55:09especially if you use that ensemble trick
- 55:11that was developed at UC Berkeley.
- 55:15But those adversarial examples don't fool us.
- 55:18It tells us that we must be using
- 55:20a very different algorithm or model family
- 55:22than current convolutional networks.
- 55:25We don't really know what the difference is yet,
- 55:27but it would be very interesting to figure that out.
- 55:30It seems to suggest that studying adversarial examples
- 55:32could tell us how to significantly improve
- 55:35our existing machine learning models.
- 55:37Even if you don't care about having an adversary,
- 55:40we might figure out something or other about
- 55:43how to make machine learning algorithms
- 55:45deal with ambiguity and unexpected inputs
- 55:48more like a human does.
- 55:52If we actually want to go out and do attacks in practice,
- 55:55there's started to be a body of research on this subject.
- 56:00Nicolas Papernot showed that he could use
- 56:03the transfer effect to fool classifiers
- 56:05hosted by MetaMind, Amazon, and Google.
- 56:09So these are all just different machine learning APIs
- 56:11where you can upload a dataset
- 56:13and the API will train the model for you.
- 56:16And then you don't actually know, in most cases,
- 56:19which model is trained for you.
- 56:21You don't have access to its weights or anything like that.
- 56:23So Nicolas would train his own copy of the model
- 56:26using the API,
- 56:27and then build a model on his own personal desktop
- 56:31where he could fool the API hosted model.
- 56:34Later, Berkeley showed you could fool Clarifai in this way.
- 56:36Yeah?
- 56:37- [Man] What did you mean when you said
- 56:39machine having adversarial models don't generally fool us?
- 56:41Because I thought that was part of the point
- 56:43that we generally do machine-generated adversarial models
- 56:46where just a few pixels change.
- 56:48- Oh, so if we look at, for example,
- 56:53like this picture of the panda.
- 56:55To us it looks like a panda.
- 56:56To most machine learning models it looks like a gibbon.
- 56:59And so this change isn't interfering with our brains,
- 57:02but it fools reliably with lots of different
- 57:04machine learning models.
- 57:08I saw somebody actually took this image of the perturbation
- 57:12out of our paper, and they pasted it
- 57:15on their Facebook profile picture
- 57:17to see if it could interfere with Facebook recognizing them.
- 57:20And they said that it did.
- 57:22I don't think that Facebook has a gibbon tag though,
- 57:25so we don't know if they managed to
- 57:29make it think that they were a gibbon.
- 57:34And one of the other things that you can do
- 57:35that's of fairly high practical significance
- 57:39is you can actually fool malware detectors.
- 57:42Catherine Gross at the University of Saarland
- 57:44wrote a paper about this.
- 57:45And there's starting to be a few others.
- 57:47There's a model called MalGAN that actually uses a GAN
- 57:50to generate adversarial examples for malware detectors.
- 57:54Another thing that matters a lot if you are interested
- 57:57in using these attacks in the real world
- 57:58and defending against them in the real world
- 58:00is that a lot of the time you don't actually
- 58:02have access to the digital input to a model.
- 58:06If you're interested in the perception system
- 58:09for a self-driving car or a robot,
- 58:11you probably don't get to actually write to the buffer
- 58:14on the robot itself.
- 58:15You just get to show the robot objects
- 58:18that it can see through a camera lens.
- 58:20So my colleague Alexey Kurakin and Samy Bengio and I
- 58:24wrote a paper where we studied if we can actually fool
- 58:27an object recognition system running on a phone,
- 58:30where it perceives the world through a camera.
- 58:33Our methodology was really straightforward.
- 58:35We just printed out several pictures
- 58:36of adversarial examples.
- 58:38And we found that the object recognition system
- 58:41run by the camera was fooled by them.
- 58:44The system on the camera is actually different
- 58:46from the model that we used
- 58:47to generate the adversarial examples.
- 58:49So we're showing not just transfer across
- 58:53the changes that happen when you use the camera,
- 58:55we're also showing that those transfer across
- 58:58the model that you use.
- 59:00So the attacker could conceivably fool
- 59:02a system that's deployed in a physical agent,
- 59:05even if they don't have access to the model on that agent
- 59:07and even if they can't interface directly with the agent
- 59:11but just subtly modify
- 59:15objects that it can see in its environment.
- 59:19Yeah?
- 59:20- [Man] Why does the,
- 59:22for the low quality camera image noise
- 59:24not affect the adversarial example?
- 59:26Because that's what one would expect.
- 59:28- Yeah, so I think a lot of that
- 59:30comes back to the maps that I showed earlier.
- 59:34If you cross over the boundary into the realm
- 59:36of adversarial examples,
- 59:38they occupy a pretty wide space
- 59:40and they're very densely packed in there.
- 59:43So if you jostle around a little bit,
- 59:45you're not going to recover from the adversarial attack.
- 59:48If the camera noise, somehow or other,
- 59:50was aligned with the negative gradient of the cost,
- 59:53then the camera could take a gradient descent step downhill
- 59:57and rescue you from the uphill step that the adversary took.
- 1:00:01But probably the camera's taking more or less
- 1:00:03something that you could model as a random direction.
- 1:00:06Like clearly when you use the camera more than once
- 1:00:09it's going to do the same thing each time,
- 1:00:11but from the point of view of how that direction
- 1:00:15relates to the image classification problem,
- 1:00:18it's more or less a random variable that you sample once.
- 1:00:22And it seems unlikely to align exactly
- 1:00:25with the normal to this class boundary.
- 1:00:33There's a lot of different defenses that we'd like to build.
- 1:00:36And it's a little bit disappointing
- 1:00:39that I'm mostly here to tell you about attacks.
- 1:00:41I'd like to tell you how to make your systems more robust.
- 1:00:44But basically every attack we've tried
- 1:00:47has failed pretty badly.
- 1:00:49And in fact, even when people have published
- 1:00:52that they successfully defended.
- 1:00:55Well, there's been several papers on arXiv
- 1:00:57over the last several months.
- 1:00:59Nicholas Carlini at Berkeley just released a paper
- 1:01:02where he shows that 10 of those defenses are broken.
- 1:01:07So this is a really, really hard problem.
- 1:01:09You can't just make it go away by using
- 1:01:11traditional regularization techniques.
- 1:01:15Particular, generative models are not enough
- 1:01:18to solve the problem.
- 1:01:19A lot of people say, "Oh the problem that's going on here
- 1:01:21"is you don't know anything about the distribution
- 1:01:23"over the input pixels.
- 1:01:25"If you could just tell
- 1:01:26"whether the input is realistic or not
- 1:01:28"then you'd be able to resist it."
- 1:01:31It turns out that what's going on here is
- 1:01:33what matters more than getting the right distributions
- 1:01:36over the inputs x,
- 1:01:37is getting the right posterior distribution
- 1:01:39over the class of labels y given inputs x.
- 1:01:42So just using a generative model
- 1:01:44is not enough to solve the problem.
- 1:01:46I think a very carefully designed generative model
- 1:01:49could possibly do it.
- 1:01:51Here I show two different modes of a bimodal distribution,
- 1:01:54and we have two different generative models
- 1:01:56that try to capture these modes.
- 1:01:58On the left we have a mixture of two Gaussians.
- 1:02:01On the right we have a mixture of two Laplacians.
- 1:02:04You can not really tell the difference visually
- 1:02:06between the distribution they impose over x,
- 1:02:09and the difference in the likelihood they assign
- 1:02:11to the training data is negligible.
- 1:02:13But the posterior distribution they assign over classes
- 1:02:16is extremely different.
- 1:02:17On the left we get a logistic regression classifier
- 1:02:20that has very high confidence
- 1:02:22out in the tails of the distribution
- 1:02:25where there is never any training data.
- 1:02:27On the right, with the Laplacian distribution,
- 1:02:29we level off to more or less 50-50.
- 1:02:33Yeah?
- 1:02:33[speaker drowned out]
- 1:02:44The issue is that it's a nonstationary distribution.
- 1:02:46So if you train it to recognize
- 1:02:48one kind of adversarial example,
- 1:02:49then it will become vulnerable to another kind
- 1:02:52that's designed to fool its detector.
- 1:02:55That's one of the category of defenses that Nicholas broke
- 1:02:59in his latest paper that he put out.
- 1:03:04So here basically the choice of exactly
- 1:03:07the family of generative model has a big effect
- 1:03:09in whether the posterior becomes deterministic or uniform,
- 1:03:14as the model extrapolates.
- 1:03:17And if we could design a really rich, deep generative model
- 1:03:21that can generate realistic ImageNet images
- 1:03:24and also correctly calculate its posterior distribution,
- 1:03:28then maybe something like this approach could work.
- 1:03:31But at the moment it's really difficult to get
- 1:03:33any of those probabilistic calculations correct.
- 1:03:36And what usually happens is,
- 1:03:38somewhere or other we make an approximation
- 1:03:40that causes the posterior distribution
- 1:03:42to extrapolate very linearly again.
- 1:03:45It's been a difficult engineering challenge
- 1:03:48to build generative models
- 1:03:50that actually capture these distributions accurately.
- 1:03:55The universal approximator theorem tells us that
- 1:03:58whatever shape we would like
- 1:04:00our classification function to have,
- 1:04:02a neural net that's big enough
- 1:04:04ought to be able to represent it.
- 1:04:06It's an open question whether we can train the neural net
- 1:04:08to have that function,
- 1:04:09but we know that we should be able to
- 1:04:11at least give the right shape.
- 1:04:13So so far we've been getting neural nets
- 1:04:15that give us these very linear decision functions,
- 1:04:18and we'd like to get something
- 1:04:19that looks a little bit more like a step function.
- 1:04:21So what if we actually just train on adversarial examples?
- 1:04:25For every input x in the training set,
- 1:04:27we also say we want you to train x plus an attack to map
- 1:04:31to the same class label as the original.
- 1:04:34It turns out that this sort of works.
- 1:04:37You can generally resist
- 1:04:39the same kind of attack that you train on.
- 1:04:41And an important consideration
- 1:04:43is making sure that you could run your attack very quickly
- 1:04:46so that you can train on lots of examples.
- 1:04:48So here the green curve at the very top,
- 1:04:51the one that doesn't really descend much at all,
- 1:04:53that's the test set error on adversarial examples
- 1:04:56if you train on clean examples only.
- 1:05:00The cyan curve that descends more or less diagonally
- 1:05:03through the middle of the plot,
- 1:05:05that's the tester on adversarial examples
- 1:05:07if you train on adversarial examples.
- 1:05:10You can see that it does actually reduce significantly.
- 1:05:13It gets down to a little bit less than 1% error.
- 1:05:16And the important thing to keep in mind here is that
- 1:05:20this is fast gradient sign method adversarial examples.
- 1:05:23It's much harder to resist
- 1:05:24iterative multi-step adversarial examples
- 1:05:27where you run an optimizer for a long time
- 1:05:29searching for a vulnerability.
- 1:05:31And another thing to keep in mind
- 1:05:33is that we're testing on
- 1:05:34the same kind of adversarial examples that we train on.
- 1:05:36It's harder to generalize
- 1:05:37from one optimization algorithm to another.
- 1:05:42By comparison, if you look at
- 1:05:46what happens on clean examples,
- 1:05:48the blue curve shows what happens
- 1:05:50on the clean test set error rate
- 1:05:53if you train only on clean examples.
- 1:05:55The red curve shows what happens
- 1:05:57if you train on both clean and adversarial examples.
- 1:06:01We see that the red curve
- 1:06:02actually drops lower than the blue curve.
- 1:06:04So on this task, training on adversarial examples
- 1:06:07actually helped us to do the original task better.
- 1:06:10This is because in the original task we were overfitting.
- 1:06:12Training on adversarial examples is good regularizer.
- 1:06:15If you're overfitting it can make you overfit less.
- 1:06:18If you're underfitting it'll just make you underfit worse.
- 1:06:21Other kinds of models besides deep neural nets
- 1:06:24don't benefit as much from adversarial training.
- 1:06:27So when we started this whole topic of study
- 1:06:29we thought that deep neural nets
- 1:06:30might be uniquely vulnerable to adversarial examples.
- 1:06:33But it turns out that actually
- 1:06:35they're one of the few models that has
- 1:06:36a clear path to resisting them.
- 1:06:38Linear models are just always going to be linear.
- 1:06:40They don't have much hope of resisting adversarial examples.
- 1:06:44Deep neural nets can be trained to be nonlinear,
- 1:06:46and so it seems like there's a path to a solution for them.
- 1:06:50Even with adversarial training,
- 1:06:52we still find that we aren't able to
- 1:06:55make models where if you optimize the input
- 1:06:57to belong to different classes,
- 1:06:59you get examples in those classes.
- 1:07:01Here I start with a CIFAR-10 truck and I turn it into
- 1:07:04each of the 10 different CIFAR-10 classes.
- 1:07:07Toward the middle of the plot
- 1:07:09you can see that the truck has started
- 1:07:10to look a little bit like a bird.
- 1:07:12But the bird class is the only one
- 1:07:13that we've come anywhere near hitting.
- 1:07:15So even with adversarial training,
- 1:07:17we're still very far from solving this problem.
- 1:07:21When we do adversarial training,
- 1:07:23we rely on having labels for all the examples.
- 1:07:25We have an image that's labeled as a bird.
- 1:07:27We make a perturbation that's designed
- 1:07:28to decrease the probability of the bird class,
- 1:07:30and we train the model
- 1:07:32that the image should still be a bird.
- 1:07:33But what if you don't have labels?
- 1:07:35It turns out that you can actually train without labels.
- 1:07:39You ask the model to predict the label of the first image.
- 1:07:42So if you've trained for a little while
- 1:07:44and your model isn't perfect yet,
- 1:07:45it might say, oh, maybe this is a bird, maybe it's a plane.
- 1:07:47There's some blue sky there,
- 1:07:49I'm not sure which of these two classes it is.
- 1:07:51Then we make an adversarial perturbation
- 1:07:53that's intended to change the guess
- 1:07:55and we just try to make it say, oh this is a truck,
- 1:07:58or something like that.
- 1:07:59It's not whatever you believed it was before.
- 1:08:01You can then train it to say
- 1:08:02that the distribution of our classes
- 1:08:04should still be the same as it was before,
- 1:08:06but this should still be considered
- 1:08:08probably a bird or a plane.
- 1:08:10This technique is called virtual adversarial training,
- 1:08:12and it was invented by Takeru Miyato.
- 1:08:15He was my Intern at Google after he did this work.
- 1:08:18At Google we invited him to come and apply his invention
- 1:08:22to text classification,
- 1:08:25because this ability to learn from unlabeled examples
- 1:08:29makes it possible to do semi-supervised learning
- 1:08:32where you learn from both unlabeled and labeled examples.
- 1:08:35And there's quite a lot of unlabeled text in the world.
- 1:08:38So we were able to bring down the error rate
- 1:08:41on several different text classification tasks
- 1:08:43by using this virtual adversarial training.
- 1:08:47Finally, there's a lot of problems where
- 1:08:49we'd like to use neural nets
- 1:08:52to guide optimization procedures.
- 1:08:54If we want to make a very, very fast car,
- 1:08:57we could imagine a neural net that looks
- 1:08:59at the blueprints for a car
- 1:09:01and predicts how fast it will go.
- 1:09:02If we could then optimize
- 1:09:04with respect to the input of the neural net
- 1:09:06and find the blueprint
- 1:09:07that it predicts would go the fastest,
- 1:09:09we could build an incredibly fast car.
- 1:09:11Unfortunately, what we get right now
- 1:09:13is not a blueprint for a fast car.
- 1:09:14We get an adversarial example that the model
- 1:09:16thinks is going to be very fast.
- 1:09:18If we're able to solve the adversarial example problem,
- 1:09:21we'll be able to solve
- 1:09:23this model-based optimization problem.
- 1:09:25I like to call model-based optimization
- 1:09:27the universal engineering machine.
- 1:09:29If we're able to do model-based optimization,
- 1:09:32we'll be able to write down a function that describes
- 1:09:34a thing that doesn't exist yet but we wish that we had.
- 1:09:37And then gradient descent and neural nets
- 1:09:39will figure out how to build it for us.
- 1:09:41We can use that to design new genes and new molecules
- 1:09:44for medicinal drugs,
- 1:09:45and new circuits
- 1:09:48to make GPUs run faster and things like that.
- 1:09:51So I think overall, solving this problem
- 1:09:53could unlock a lot of potential technological advances.
- 1:09:58In conclusion, attacking machine learning models
- 1:10:00is extremely easy,
- 1:10:01and defending them is extremely difficult.
- 1:10:03If you use adversarial training
- 1:10:06you can get a little bit of a defense,
- 1:10:07but there's still many caveats
- 1:10:09associated with that defense.
- 1:10:11Adversarial training and virtual adversarial training
- 1:10:13also make it possible to regularize your model
- 1:10:16and even learn from unlabeled data
- 1:10:18so you can do better on regular test examples,
- 1:10:21even if you're not concerned about facing an adversary.
- 1:10:23And finally, if we're able to solve all of these problems,
- 1:10:26we'll be able to build a black box model-based optimization
- 1:10:29system that can solve all kinds of engineering problems
- 1:10:32that are holding us back in many different fields.
- 1:10:35I think I have a few minutes left for questions.
- 1:10:39[audience applauds]
- 1:10:47[speaker drowned out]
- 1:10:57Yeah.
- 1:11:15Oh, so,
- 1:11:16there's some determinism
- 1:11:18to the choice of those 50 directions.
- 1:11:22Oh right, yeah.
- 1:11:23So repeating the questions.
- 1:11:24I've said that the same perturbation
- 1:11:26can fool many different models
- 1:11:27or the same perturbation can be applied
- 1:11:29to many different clean examples.
- 1:11:31I've also said that the subspace
- 1:11:33of adversarial perturbations is only about 50 dimensional,
- 1:11:37even if the input dimension is 3,000 dimensional.
- 1:11:40So how is it that these subspaces intersect?
- 1:11:43The reason is that the choice of the subspace directions
- 1:11:47is not completely random.
- 1:11:49It's generally going to be something like
- 1:11:51pointing from one class centroid to another class centroid.
- 1:11:55And if you look at that vector and visualize it as an image,
- 1:12:00it might not be meaningful to a human
- 1:12:03just because humans aren't very good
- 1:12:04at imagining what class centroids look like.
- 1:12:06And we're really bad at imagining
- 1:12:07differences between centroids.
- 1:12:10But there is more or less this systematic effect
- 1:12:12that causes different models to learn
- 1:12:14similar linear functions,
- 1:12:17just because they're trying to solve the same task.
- 1:12:22[speaker drowned out]
- 1:12:27Yeah, so the question is, is it possible to identify
- 1:12:29which layer contributes the most to this issue?
- 1:12:33One thing is that if you,
- 1:12:36the last layer is somewhat important.
- 1:12:39Because, say that you made a feature extractor
- 1:12:42that's completely robust to adversarial perturbations
- 1:12:45and can shrink them to be very, very small,
- 1:12:48and then the last layer is still linear.
- 1:12:51Then it has all the problems that are typically associated
- 1:12:53with linear models.
- 1:12:57And generally you can do adversarial training
- 1:13:00where you perturb all the different layers,
- 1:13:02all the hidden layers as well as the input.
- 1:13:04In this lecture I only described perturbing the input
- 1:13:06because it seems like that's where
- 1:13:07most of the benefit comes from.
- 1:13:09The one thing that you can't do with adversarial training
- 1:13:11is perturb the very last layer before the softmax,
- 1:13:14because that linear layer at the end
- 1:13:15has no way of learning to resist the perturbations.
- 1:13:18Doing adversarial training at that layer
- 1:13:20usually just breaks the whole process.
- 1:13:23But other than that, it seems very problem dependent.
- 1:13:27There's a paper by Sara Sabour and her collaborators
- 1:13:30called Adversarial Manipulation of Deep Representations,
- 1:13:34where they design adversarial examples
- 1:13:36that are intended to fool different layers of the net.
- 1:13:41They report some things about, like,
- 1:13:43how large of a perturbation is needed at the input
- 1:13:45to get different sizes of perturbation
- 1:13:47at different hidden layers.
- 1:13:49I suspect that if you trained the model
- 1:13:50to resist perturbations at one layer,
- 1:13:52then another layer would become more vulnerable
- 1:13:54and it would be like a moving target.
- 1:14:00[speaker drowned out]
- 1:14:09Yes, so the question is,
- 1:14:10how many adversarial examples are needed
- 1:14:12to improve the misclassification rate?
- 1:14:15Some of our plots we include learning curves.
- 1:14:20Or some of our papers we include learning curves,
- 1:14:22so you can actually see,
- 1:14:25like in this one here.
- 1:14:26Every time we do an epoch we've generated the same
- 1:14:29number of adversarial examples
- 1:14:31as there are training examples.
- 1:14:33So every epoch here is 50,000 adversarial examples.
- 1:14:37You can see that adversarial training is a very
- 1:14:41data hungry process.
- 1:14:43You need to make new adversarial examples
- 1:14:45every time you update the weights.
- 1:14:47And they're constantly changing in reaction to
- 1:14:51whatever the model has learned most recently.
- 1:14:55[speaker drowned out]
- 1:15:07Oh, the model-based optimization, yeah.
- 1:15:11Yeah, so the question is just to
- 1:15:13elaborate further on this problem.
- 1:15:16So most of the time that we have a machine learning model,
- 1:15:20it's something like a classifier or a regression model
- 1:15:23where we give it an input from the test set
- 1:15:26and it gives us an output.
- 1:15:29And usually that input is randomly occurring
- 1:15:31and comes from the same distribution as the training set.
- 1:15:34We usually just run the model, get its prediction,
- 1:15:37and then we're done with it.
- 1:15:39Sometimes we have feedback loops,
- 1:15:42like for recommender systems.
- 1:15:44If you work at Netflix and you recommend
- 1:15:47a movie to a viewer, then they're more likely
- 1:15:50to watch that movie and then rate it,
- 1:15:52and then there's going to be more ratings of it
- 1:15:54in your training set
- 1:15:55so you'll recommend it to more people in the future.
- 1:15:57So there's this feedback loop
- 1:15:58from the output of your model to the input.
- 1:16:00Most of the time when we build machine vision systems,
- 1:16:04there's no feedback loop from their output to their input.
- 1:16:08If we imagine a setting
- 1:16:09where we start using an optimization algorithm
- 1:16:11to find inputs that maximize some property of the output,
- 1:16:17like if we have a model that looks
- 1:16:18at the blueprints of a car
- 1:16:20and outputs the expected speed of the car,
- 1:16:24then we could use gradient ascent
- 1:16:27to look for the blueprints that correspond
- 1:16:29to the fastest possible car.
- 1:16:31Or for example if we're designing a medicine,
- 1:16:33we could look for the molecular structure
- 1:16:36that we think is most likely to cure some form of cancer,
- 1:16:40or the least likely to cause
- 1:16:42some kind of liver toxicity effect.
- 1:16:45The problem is that once we start using optimization
- 1:16:49to look for these inputs
- 1:16:50that maximize the output of the model,
- 1:16:53the input is no longer an independent sample
- 1:16:56from the same distribution
- 1:16:58as we used at the training set time.
- 1:17:00The model is now guiding the process
- 1:17:04that generates the data.
- 1:17:06So we end up finding essentially adversarial examples.
- 1:17:11Instead of the model telling us
- 1:17:13how we can improve the input,
- 1:17:15what we usually find in practice
- 1:17:16is that we've got an input that fools the model
- 1:17:19into thinking that the input corresponds to something great.
- 1:17:23So we'd find molecules that are very toxic
- 1:17:26but the model thinks they're very non-toxic.
- 1:17:28Or we'd find cars that are very slow
- 1:17:30but the model thinks are very fast.
- 1:17:35[speaker drowned out]
- 1:17:54Yeah, so the question is,
- 1:17:56here the frog class is boosted by going
- 1:17:58in either the positive or negative adversarial direction.
- 1:18:01And in some of the other slides, like these maps,
- 1:18:06you don't get that effect where subtracting epsilon off
- 1:18:09eventually boosts the adversarial class.
- 1:18:12Part of what's going on is
- 1:18:13I think I'm using larger epsilon here.
- 1:18:16And so you might eventually see that effect
- 1:18:18if I'd made these maps wider.
- 1:18:20I made the maps narrower because
- 1:18:21it's like quadratic time to build a 2D map
- 1:18:25and it's linear time to build a 1D cross section.
- 1:18:29So I just didn't afford the GPU time
- 1:18:33to make the maps quite as wide.
- 1:18:35I also think that this might just be
- 1:18:37a weird effect that happened randomly on this one example.
- 1:18:40It's not something that I remember being used to seeing
- 1:18:42a lot of the time.
- 1:18:43Most things that I observe
- 1:18:45don't happen perfectly consistently.
- 1:18:47But if they happen, like, 80% of the time
- 1:18:50then I'll put them in my slide.
- 1:18:52A lot of what we're doing is trying trying to figure out
- 1:18:54more or less what's going on,
- 1:18:56and so if we find that something happens 80% of the time,
- 1:18:58then I consider it to be the dominant phenomenon
- 1:19:02that we're trying to explain.
- 1:19:03And after we've got a better explanation for that
- 1:19:06then I might start to try to explain
- 1:19:07some of the weirder things that happen,
- 1:19:09like the frog happening with negative epsilon.
- 1:19:15[speaker drowned out]
- 1:19:22I didn't fully understand the question.
- 1:19:24It's about the dimensionality of the adversarial?
- 1:19:34Oh, okay.
- 1:19:35So the question is, how is the dimension
- 1:19:37of the adversarial subspace related
- 1:19:39to the dimension of the input?
- 1:19:40And my answer is somewhat embarrassing,
- 1:19:44which is that we've only run this method on two datasets,
- 1:19:47so we actually don't have a good idea yet.
- 1:19:49But I think it's something interesting to study.
- 1:19:53If I remember correctly, my coauthors open sourced our code.
- 1:19:57So you could probably run it on ImageNet
- 1:19:59without too much trouble.
- 1:20:02My contribution to that paper was in
- 1:20:04the week that I was unemployed
- 1:20:06between working at OpenAI and working at Google,
- 1:20:09so I had access to no GPUS
- 1:20:11and I ran that experiment on my laptop on CPU,
- 1:20:14so it's only really small datasets. [chuckles]
- 1:20:19[speaker drowned out]
- 1:20:40Oh, so the question is, do we end up perturbing
- 1:20:44clean examples to low confidence adversarial examples?
- 1:20:47Yeah, in practice we usually find that
- 1:20:50we can get very high confidence on the output examples.
- 1:20:53One thing in high dimensions that's a little bit unintuitive
- 1:20:57is that just getting the sign right
- 1:21:00on very many of the input pixels
- 1:21:03is enough to get a really strong response.
- 1:21:06So the angle between the weight vector
- 1:21:09matters a lot more than the exact coordinates
- 1:21:13in high dimensional systems.
- 1:21:18Does that make enough sense?
- 1:21:20Yeah, okay.
- 1:21:21- [Man] So we're actually going to [mumbles].
- 1:21:23So if you guys need to leave, that's fine.
- 1:21:26But let's thank our speaker one more time
- 1:21:28for getting-- [audience applauds]
About this transcript
This page contains the full transcript of Lecture 16 | Adversarial Examples and Adversarial Training by Stanford University School of Engineering, generated from the public captions YouTube serves with the video. The transcript has 13,674 words across 1,853 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to choose a caption track available on the video.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, caption language selection, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.