YouTube2Text

Lecture 16 | Adversarial Examples and Adversarial Training — Transcript

by Stanford University School of Engineering · 13,674 words · 1,853 segments · language en · Watch on YouTube

Full transcript

  1. 0:08- Okay, sounds like it is.
  2. 0:10I'll be telling you about adversarial examples
  3. 0:12and adversarial training today.
  4. 0:15Thank you.
  5. 0:18As an overview, I will start off by telling you
  6. 0:20what adversarial examples are,
  7. 0:22and then I'll explain why they happen,
  8. 0:26why it's possible for them to exist.
  9. 0:28I'll talk a little bit about how adversarial examples
  10. 0:31pose real world security threats,
  11. 0:33that they can actually be used to compromise
  12. 0:36systems built on machine learning.
  13. 0:38I'll tell you what the defenses are so far,
  14. 0:41but mostly defenses are an open research problem
  15. 0:43that I hope some of you will move on to tackle.
  16. 0:47And then finally I'll tell you
  17. 0:49how to use adversarial examples
  18. 0:50to improve other machine learning algorithms
  19. 0:53even if you want to build a machine learning algorithm
  20. 0:56that won't face a real world adversary.
  21. 1:00Looking at the big picture and the context for this lecture,
  22. 1:05I think most of you are probably here
  23. 1:07because you've heard how incredibly powerful
  24. 1:10and successful machine learning is,
  25. 1:12that very many different tasks
  26. 1:14that could not be solved with software before
  27. 1:17are now solvable thanks to deep learning
  28. 1:20and convolutional networks and gradient descent.
  29. 1:23All of these technologies that are working really well.
  30. 1:27Until just a few years ago,
  31. 1:28these technologies didn't really work.
  32. 1:30In about 2013, we started to see
  33. 1:33that deep learning achieved human level performance
  34. 1:37at a lot of different tasks.
  35. 1:39We saw that convolutional nets
  36. 1:40could recognize objects and images
  37. 1:43and score about the same as people in those benchmarks,
  38. 1:47with the caveat that part of the reason that
  39. 1:49algorithms score as well as people
  40. 1:51is that people can't tell
  41. 1:52Alaskan Huskies from Siberian Huskies very well,
  42. 1:55but modulo the strangeness of the benchmarks
  43. 1:58deep learning caught up to about human level performance
  44. 2:01for object recognition in about 2013.
  45. 2:05That same year, we also saw that object recognition
  46. 2:08applied to human faces caught up to about human level.
  47. 2:12That suddenly we had computers
  48. 2:14that could recognize faces about as well as
  49. 2:17you or I could recognize faces of strangers.
  50. 2:21You can recognize the faces of your friends and family
  51. 2:24better than a computer, but when you're dealing
  52. 2:27with people that you haven't had a lot of experience with
  53. 2:30the computer caught up to us in about 2013.
  54. 2:34We also saw that computers caught up
  55. 2:36to humans for reading type written fonts in photos
  56. 2:41in about 2013.
  57. 2:42It even got the point that we could no longer use CAPTCHAs
  58. 2:46to tell whether a user of a webpage is human or not
  59. 2:50because the convolutional network
  60. 2:52is better at reading obfuscated text than a human is.
  61. 2:56So with this context today
  62. 2:58of deep learning working really well
  63. 3:00especially for computer vision
  64. 3:02it's a little bit unusual to think about
  65. 3:05the computer making a mistake.
  66. 3:07Before about 2013, nobody was ever surprised
  67. 3:10if the computer made a mistake.
  68. 3:12That was the rule not the exception,
  69. 3:14and so today's topic which is all about
  70. 3:16unusual mistakes that deep learning algorithms make
  71. 3:20this topic wasn't really a serious avenue of study
  72. 3:24until the algorithms started to work well most of the time,
  73. 3:28and now people study the way that they break
  74. 3:31now that that's actually the exception rather than the rule.
  75. 3:36An adversarial example is an example
  76. 3:39that has been carefully computed to be misclassified.
  77. 3:43In a lot of cases we're able to make the new image
  78. 3:45indistinguishable to a human observer
  79. 3:48from the original image.
  80. 3:50Here, I show you one where we start with a panda.
  81. 3:52On the left this is a panda
  82. 3:54that has not been modified in any way,
  83. 3:57and the convolutional network trained on the image
  84. 3:59in that dataset is able to recognize it as being a panda.
  85. 4:03One interesting thing is that the model
  86. 4:05doesn't have a whole lot of confidence in that decision.
  87. 4:08It assigns about 60% probability
  88. 4:10to this image being a panda.
  89. 4:13If we then compute exactly the way
  90. 4:16that we could modify the image
  91. 4:17to cause the convolutional network to make a mistake
  92. 4:20we find that the optimal direction
  93. 4:23to move all the pixels is given by this image in the middle.
  94. 4:27To a human it looks a lot like noise.
  95. 4:29It's not actually noise.
  96. 4:31It's carefully computed as a function
  97. 4:33of the parameters of the network.
  98. 4:34There's actually a lot of structure there.
  99. 4:36If we multiply that image of the structured attack
  100. 4:41by a very small coefficient and add it to the original panda
  101. 4:45we get an image that a human can't tell
  102. 4:48from the original panda.
  103. 4:49In fact, on this slide there is no difference
  104. 4:52between the panda on the left
  105. 4:54and the panda on the right.
  106. 4:56When we present the image to convolutional network
  107. 4:58we use 32-bit floating point values.
  108. 5:01The monitor here can only display eight bits
  109. 5:05of color resolution, and we have made a change
  110. 5:07that's just barely too small
  111. 5:09to affect the smallest of those eight bits,
  112. 5:12but it effects the other 24
  113. 5:14of the 32-bit floating point representation,
  114. 5:17and that little tiny change is enough
  115. 5:19to fool the convolutional network
  116. 5:21into recognizing this image of a panda as being a gibbon.
  117. 5:26Another interesting thing is that
  118. 5:28it doesn't just change the class.
  119. 5:29It's not that we just barely found the decision boundary
  120. 5:32and just barely stepped across it.
  121. 5:34The convolutional network actually has much more confidence
  122. 5:37in its incorrect prediction,
  123. 5:40that the image on the right is a gibbon,
  124. 5:42than it had for the original being a panda.
  125. 5:45On the right, it believes that the image
  126. 5:47is a gibbon with 99.9% probability,
  127. 5:50so before it thought that there was about
  128. 5:531/3 chance that it was something other than a panda,
  129. 5:57and now it's about as certain as it can possibly be
  130. 6:00that it's a gibbon.
  131. 6:02As a little bit of history, people have studied ways
  132. 6:05of computing attacks to fool
  133. 6:07different machine learning models
  134. 6:09since at least about 2004, and maybe earlier.
  135. 6:13For a long time this was done in the context
  136. 6:15of fooling spam detectors.
  137. 6:17In about 2013, Battista Biggio found
  138. 6:21that you could fool neural networks in this way,
  139. 6:24and around the same time my colleague, Christian Szegedy,
  140. 6:27found that you could make this kind of attack
  141. 6:29against deep neural networks
  142. 6:30just by using an optimization algorithm
  143. 6:33to search on the input of the image.
  144. 6:36A lot of what I'll be telling you about today
  145. 6:37is my own follow-up work on this topic,
  146. 6:40but I've spent a lot of my career over the past few years
  147. 6:43understanding why these attacks are possible
  148. 6:46and why it's so easy to fool these convolutional networks.
  149. 6:52When my colleague, Christian,
  150. 6:54first discovered this phenomenon
  151. 6:57independently from Battista Biggio but around the same time,
  152. 7:01he found that it was actually a result
  153. 7:05of a visualization he was trying to make.
  154. 7:08He wasn't studying security.
  155. 7:10He wasn't studying how to fool a neural network.
  156. 7:12Instead, he had a convolutional network
  157. 7:14that could recognize objects very well,
  158. 7:16and he wants to understand how it worked,
  159. 7:19so he thought that maybe he could take an image of a scene,
  160. 7:24for example a picture of a ship,
  161. 7:26and he could gradually transform that image
  162. 7:28into something that the network would recognize
  163. 7:31as being an airplane.
  164. 7:33Over the course of that transformation,
  165. 7:35he could see how the features of the input change.
  166. 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,
  167. 7:44or you might expect that the ship
  168. 7:46would grow wings to look more like an airplane.
  169. 7:48You could conclude from that that the convolution
  170. 7:51uses the blue sky or uses the wings to recognize airplanes.
  171. 7:56That's actually not really what happened at all.
  172. 7:59Each of these panels here shows an animation
  173. 8:01that you read left to right, top to bottom.
  174. 8:03Each panel is another step of gradient ascent
  175. 8:06on the log probability that the input is an airplane
  176. 8:11according to a convolutional net model,
  177. 8:14and then we follow the gradient on the input to the image.
  178. 8:18You're probably used to following the gradient
  179. 8:20on the parameters of a model.
  180. 8:22You can use the back propagation algorithm
  181. 8:23to compute the gradient on the input image
  182. 8:26using exactly the same procedure
  183. 8:28that you would use to compute the gradient
  184. 8:29on the parameters.
  185. 8:31In this animation of the ship in the upper left,
  186. 8:34we see five panels that all look basically the same.
  187. 8:37Gradient descent doesn't seem
  188. 8:39to have moved the image at all,
  189. 8:40but by the last panel the network is completely confident
  190. 8:43that this is an airplane.
  191. 8:45When you first code up this kind of experiment,
  192. 8:47especially if you don't know what's going to happen,
  193. 8:49it feels a little bit like you have a bug in your script
  194. 8:51and you're just displaying
  195. 8:52the same image over and over again.
  196. 8:54The first time I did it,
  197. 8:55I couldn't believe it was happening,
  198. 8:58and I had to open up the images in NumPy,
  199. 9:00and take the difference of them,
  200. 9:02and make sure that there was actually
  201. 9:03a non-zero difference in there, but there is.
  202. 9:07I show several different animations here
  203. 9:09of a ship, a car, a cat, and a truck.
  204. 9:13The only one where I actually see any change at all
  205. 9:15is the image of the cat.
  206. 9:18The color of the cat's face changes a little bit,
  207. 9:21and maybe it becomes a little bit more
  208. 9:23like the color of a metal airplane.
  209. 9:25Other than that, I don't see any changes
  210. 9:28in any of these animations,
  211. 9:29and I don't see anything very suggestive of an airplane.
  212. 9:33So gradient descent, rather than turning the input
  213. 9:36into an example of an airplane,
  214. 9:39has found an image that fools the network
  215. 9:42into thinking that the input is an airplane.
  216. 9:45And if we were malicious attackers
  217. 9:47we didn't even have to work very hard to figure out
  218. 9:49how to fool the network.
  219. 9:51We just asked the network
  220. 9:52to give us an image of an airplane,
  221. 9:53and it gave us something that fools it into thinking
  222. 9:56that the input is an airplane.
  223. 10:00When Christian first published this work,
  224. 10:02a lot of articles came out with titles like,
  225. 10:05The Flaw Looking At Every Deep Neural Network,
  226. 10:07or Deep Learning has Deep Flaws.
  227. 10:10It's important to remember that these vulnerabilities
  228. 10:12apply to essentially every machine learning algorithm
  229. 10:15that we've studied so far.
  230. 10:18Some of them like RBF networks
  231. 10:20and partisan density estimators
  232. 10:22are able to resist this effect somewhat,
  233. 10:24but even very simple machine learning algorithms
  234. 10:27are highly vulnerable to adversarial examples.
  235. 10:32In this image, I show an animation
  236. 10:33of what happens when we attack a linear model,
  237. 10:37so it's not a deep algorithm at all.
  238. 10:38It's just a shallow softmax model.
  239. 10:41You multiply by a matrix, you add a vector of bias terms,
  240. 10:45you apply the softmax function,
  241. 10:47and you've got your probability distribution
  242. 10:48over the 10 MNIST classes.
  243. 10:51At the upper left, I start with an image of a nine,
  244. 10:54and then as we move left to right, top to bottom,
  245. 10:57I gradually transform it to be a zero.
  246. 11:00Where I've drawn the yellow box,
  247. 11:02the model assigns high probability to it being a zero.
  248. 11:05I forget exactly what my threshold was for high probability,
  249. 11:08but I think it was around 0.9 or so.
  250. 11:11Then as we move to the second row,
  251. 11:13I transform it into a one,
  252. 11:15and the second yellow box indicates
  253. 11:17where we've successfully fooled the model
  254. 11:18into thinking it's a one with high probability.
  255. 11:21And then as you read the rest of the yellow boxes
  256. 11:23left to right, top to bottom,
  257. 11:25we go through the twos, threes, fours, and so on,
  258. 11:27until finally at the lower right
  259. 11:29we have a nine that has a yellow box around it,
  260. 11:31and it actually looks like a nine,
  261. 11:33but in this case the only reason
  262. 11:35it actually looks like a nine
  263. 11:36is that we started the whole process with a nine.
  264. 11:39We successfully swept through all 10 classes of MNIST
  265. 11:43without substantially changing the image of the digit
  266. 11:46in any way that would interfere with human recognition.
  267. 11:50This linear model was actually extremely easy to fool.
  268. 11:55Besides linear models, we've also seen
  269. 11:57that we can fool many different kinds of linear models
  270. 12:01including logistic regression and SVMs.
  271. 12:04We've also found that we can fool decision trees,
  272. 12:07and to a lesser extent, nearest neighbors classifiers.
  273. 12:13We wanted to explain exactly why this happens.
  274. 12:16Back in about 2014, after we'd published the original paper
  275. 12:20where we'd said that these problems exist,
  276. 12:22we were trying to figure out why they happen.
  277. 12:25When we wrote our first paper,
  278. 12:27we thought that basically this is a form of overfitting,
  279. 12:30that you have a very complicated deep neural network,
  280. 12:34it learns to fit the training set,
  281. 12:36its behavior on the test set is somewhat undefined,
  282. 12:39and then it makes random mistakes
  283. 12:41that an attacker can exploit.
  284. 12:44Let's walk through what that story looks like
  285. 12:45somewhat concretely.
  286. 12:47I have here a training set of three blue X's
  287. 12:50and three green O's.
  288. 12:53We want to make a classifier
  289. 12:54that can recognize X's and recognize O's.
  290. 12:57We have a very complicated classifier
  291. 12:59that can easily fit the training set,
  292. 13:01so we represent everywhere it believes
  293. 13:03X's should be with blobs of blue color,
  294. 13:06and I've drawn a blob of blue
  295. 13:08around all of the training set X's,
  296. 13:10so it correctly classifies the training set.
  297. 13:13It also has a blob of green mass showing where the O's are,
  298. 13:17and it successfully fits all of the green training set O's,
  299. 13:21but then because this is a very complicated function
  300. 13:24and it has just way more parameters
  301. 13:26than it actually needs to represent the training task,
  302. 13:30it throws little blobs of probability mass
  303. 13:33around the rest of space randomly.
  304. 13:35On the left there's a blob of green space
  305. 13:37that's kind of near the training set X's,
  306. 13:40and I've drawn a red X there to show
  307. 13:42that maybe this would be an adversarial example
  308. 13:43where we expect the classification to be X,
  309. 13:46but the model assigns O.
  310. 13:48On the right, I've shown that there's a red O
  311. 13:51where we have another adversarial example.
  312. 13:53We're very near the other O's.
  313. 13:55We might expect the model to assign this class to be an O,
  314. 13:58and yet because it's drawn blue mass there
  315. 14:00it's actually assigning it to be an X.
  316. 14:04If overfitting is really the story
  317. 14:05then each adversarial example is more or less
  318. 14:09the result of bad luck and also more or less unique.
  319. 14:12If we fit the model again
  320. 14:14or we fit a slightly different model
  321. 14:16we would expect to make different random mistakes
  322. 14:19on this points that are off the training set,
  323. 14:22but that was actually not what we found at all.
  324. 14:25We found that many different models would misclassify
  325. 14:28the same adversarial examples,
  326. 14:30and they would assign the same class to them.
  327. 14:33We also found that if we took the difference
  328. 14:36between an original example and an adversarial example
  329. 14:40then we had a direction in input space
  330. 14:43and we could add that same offset vector
  331. 14:46to any clean example, and we would almost always
  332. 14:49get an adversarial example as a result.
  333. 14:52So we started to realize
  334. 14:52that there was systematic effect going on here,
  335. 14:55not just a random effect.
  336. 14:57That led us to another idea
  337. 14:59which is that adversarial examples
  338. 15:01might actually be more like underfitting
  339. 15:03rather than overfitting.
  340. 15:05They might actually come from the model being too linear.
  341. 15:09Here I draw the same task again
  342. 15:11where we have the same manifold of O's
  343. 15:13and the same line of X's,
  344. 15:15and this time I fit a linear model to the data set
  345. 15:19rather than fitting a high capacity, non-linear model to it.
  346. 15:23We see that we get a dividing hyperplane
  347. 15:26running in between the two classes.
  348. 15:29This hyperplane doesn't really capture
  349. 15:30the true structure of the classes.
  350. 15:33The O's are clearly arranged in a C-shaped manifold.
  351. 15:37If we keep walking past the end of the O's,
  352. 15:40we've crossed the decision boundary and we've drawn a red O
  353. 15:43where even though we're very near the decision boundary
  354. 15:46and near other O's we believe that it is now an X.
  355. 15:49Similarly we can take steps that go from near X's
  356. 15:53to just over the line that are classified as O's.
  357. 15:57Another thing that's somewhat unusual about this plot
  358. 15:59is that if we look at the lower left or upper right corners
  359. 16:03these corners are very confidently classified
  360. 16:05as being X's on the lower left or O's on the upper right
  361. 16:09even though we've never seen any data over there at all.
  362. 16:12The linear model family forces the model
  363. 16:14to have very high confidence in these regions
  364. 16:17that are very far from the decision boundary.
  365. 16:22We've seen that linear models can actually assign
  366. 16:25really unusual confidence as you move very far
  367. 16:28from the decision boundary,
  368. 16:30even if there isn't any data there,
  369. 16:31but are deep neural networks actually
  370. 16:34anything like linear models?
  371. 16:36Could linear models actually explain anything
  372. 16:38about how it is that deep neural nets fail?
  373. 16:41It turns out that modern deep neural nets
  374. 16:43are actually very piecewise linear,
  375. 16:45so rather than being a single linear function
  376. 16:47they are piecewise linear
  377. 16:49with maybe not that many linear pieces.
  378. 16:53If we use rectified linear units
  379. 16:55then the mapping from the input image to the output logits
  380. 17:00is literally a piecewise linear function.
  381. 17:03By the logits I mean the un-normalized log probabilities
  382. 17:06before we apply the softmax op at the output of the model.
  383. 17:11There are other neural networks
  384. 17:13like maxout networks that are also
  385. 17:14literally piecewise linear.
  386. 17:17And then there are several that become very close to it.
  387. 17:19Before rectified linear units became popular
  388. 17:22most people used to use sigmoid units of one form or another
  389. 17:27either logistic sigmoid or hyperbolic tangent units.
  390. 17:30These sigmoidal units have to be carefully tuned,
  391. 17:33especially at initialization
  392. 17:35so that you spend most of your time
  393. 17:37near the center of the sigmoid
  394. 17:40where the sigmoid is approximately linear.
  395. 17:43Then finally, the LSTM, a kind of recurrent network
  396. 17:46that is one of the most popular recurrent networks today,
  397. 17:49uses addition from one time step to the next
  398. 17:52in order to accumulate and remember information over time.
  399. 17:56Addition is a particularly simple form of linearity,
  400. 18:00so we can see that the interaction
  401. 18:01from a very distant time step in the past and the present
  402. 18:06is highly linear within an LSTM.
  403. 18:09Now to be clear, I'm speaking about the mapping
  404. 18:11from the input of the model to the output of the model.
  405. 18:14That's what I'm saying is close to being linear
  406. 18:17or is piecewise linear with relatively few pieces.
  407. 18:21The mapping from the parameters of the network
  408. 18:23to the output of the network is non-linear
  409. 18:26because the weight matrices at each layer of the network
  410. 18:29are multiplied together.
  411. 18:31So we actually get extremely non-linear reactions
  412. 18:34between parameters and the output.
  413. 18:36That's what makes training a neural network so difficult.
  414. 18:39But the mapping from the input to the output
  415. 18:42is much more linear and predictable,
  416. 18:45and it means that optimization problems
  417. 18:47that aim to optimize the input to the model
  418. 18:50are much easier than optimization problems
  419. 18:53that aim to optimize the parameters.
  420. 18:57If we go and look for this happening in practice
  421. 18:59we can take a convolutional network
  422. 19:01and trace out a one-dimensional path
  423. 19:04through its input space.
  424. 19:07So what we're doing here is we're choosing a clean example.
  425. 19:09It's an image of a white car on a red background,
  426. 19:12and we are choosing a direction
  427. 19:14that will travel through space.
  428. 19:16We are going to have a coefficient epsilon
  429. 19:19that we multiply by this direction.
  430. 19:21When epsilon is negative 30,
  431. 19:22like at the left end of the plot,
  432. 19:24we're subtracting off a lot of this unit vector direction.
  433. 19:28When epsilon is zero, like in the middle of the plot,
  434. 19:30we're visiting the original image from the data set,
  435. 19:33and when epsilon is positive 30,
  436. 19:36like at the right end of the plot,
  437. 19:37we're adding this direction onto the input.
  438. 19:42In the panel on the left, I show you an animation
  439. 19:45where we move from epsilon equals negative 30
  440. 19:47as up to epsilon equals positive 30.
  441. 19:50You read the animation left to right, top to bottom,
  442. 19:53and everywhere that there's a yellow box
  443. 19:56the input has correctly recognized as being a car.
  444. 20:01On the upper left, you see that it looks mostly blue.
  445. 20:04On the lower right, it's hard to tell what's going on.
  446. 20:07It's kind of reddish and so on.
  447. 20:10In the middle row, just after where the yellow boxes end
  448. 20:13you can see pretty clearly
  449. 20:14that it's a car on a red background,
  450. 20:17though the image is small on these slides.
  451. 20:20What's interesting to look at here is the logits
  452. 20:23that the model outputs.
  453. 20:25This is a deep convolutional rectified linear unit network.
  454. 20:30Because it uses rectified linear units,
  455. 20:32we know that the output is a piecewise linear function
  456. 20:36of the input to the model.
  457. 20:38The main question we're asking by making this plot
  458. 20:40is how many different pieces
  459. 20:42does this piecewise linear function have
  460. 20:45if we look at one particular cross section.
  461. 20:48You might think that maybe a deep net
  462. 20:50is going to represent some extremely
  463. 20:52wiggly complicated function with lots and lots
  464. 20:54of linear pieces no matter which cross section you look in.
  465. 20:58Or we might find that it has more or less two pieces
  466. 21:01for each function we look at.
  467. 21:04Each of the different curves on this plot
  468. 21:07is the logits for a different class.
  469. 21:10We see that out at the tails of the plot
  470. 21:13that the frog class is the most likely,
  471. 21:16and the frog class basically looks like
  472. 21:18a big v-shaped function.
  473. 21:21The logits for the frog class become very high
  474. 21:24when epsilon is negative 30 or positive 30,
  475. 21:27and they drop down and become a little bit negative
  476. 21:29when epsilon is zero.
  477. 21:32The car class, listed as automobile here,
  478. 21:37it's actually high in the middle,
  479. 21:39and the car is correctly recognized.
  480. 21:42As we sweep out to very negative epsilon,
  481. 21:44the logits for the car class do increase,
  482. 21:47but they don't increase nearly as quickly
  483. 21:49as the logits for the frog class.
  484. 21:51So, we've found a direction
  485. 21:52that's associated with the frog class
  486. 21:54and as we follow it out to a relatively large perturbation,
  487. 21:59we find that the model extrapolates linearly
  488. 22:02and begins to make a very unreasonable prediction
  489. 22:04that the frog class is extremely likely
  490. 22:07just because we've moved for a long time
  491. 22:09in this direction that was locally associated
  492. 22:12with the frog class being more likely.
  493. 22:17When we actually go and construct adversarial examples,
  494. 22:20we need to remember that we're able to get
  495. 22:23quite a large perturbation
  496. 22:24without changing the image very much
  497. 22:26as far as a human being is concerned.
  498. 22:30So here I show you a handwritten digit three,
  499. 22:33and I'm going to change it in several different ways,
  500. 22:36and all of these changes have
  501. 22:37the same L2 norm perturbation.
  502. 22:40In the top row, I'm going to change the three into a seven
  503. 22:44just by looking for the nearest seven in the training set.
  504. 22:47The difference between those two
  505. 22:49is this image that looks a little bit like the seven
  506. 22:53wrapped in some black lines.
  507. 22:55So here white pixels in the middle image
  508. 22:57in the perturbation column,
  509. 22:59the white pixels represent adding something
  510. 23:02and black pixels represent subtracting something
  511. 23:04as you move from the left column to the right column.
  512. 23:08So when we take the three and we apply this perturbation
  513. 23:11that transforms it into a seven,
  514. 23:13we can measure the L2 norm of that perturbation.
  515. 23:16And it turns out to have an L2 norm of 3.96.
  516. 23:20That gives you kind of a reference
  517. 23:21for how big these perturbations can be.
  518. 23:24In the middle row, we apply a perturbation
  519. 23:26of exactly the same size,
  520. 23:28but with the direction chosen randomly.
  521. 23:30In this case we don't actually change
  522. 23:32the class of the three at all,
  523. 23:33we just get some random noise
  524. 23:35that didn't really change the class.
  525. 23:37A human could still easily read it as being a three.
  526. 23:41And then finally at the very bottom row,
  527. 23:44we take the three and we just erase a piece of it
  528. 23:46with a perturbation of the same norm
  529. 23:48and we turn it into something
  530. 23:50that doesn't have any class at all.
  531. 23:52It's not a three, it's not a seven,
  532. 23:53it's just a defective input.
  533. 23:56All of these changes can happen
  534. 23:57with the same L2 norm perturbation.
  535. 24:00And actually a lot of the time with adversarial examples,
  536. 24:03you make perturbations that have an even larger L2 norm.
  537. 24:06What's going on is that
  538. 24:07there are several different pixels in the image,
  539. 24:09and so small changes to individual pixels
  540. 24:12can add up to relatively large vectors.
  541. 24:15For larger datasets like ImageNet,
  542. 24:17where there's even more pixels,
  543. 24:18you can make very small changes to each pixel
  544. 24:21that travel very far in vector space
  545. 24:24as measured by the L2 norm.
  546. 24:26That means that you can actually make changes
  547. 24:28that are almost imperceptible
  548. 24:30but actually move you really far
  549. 24:31and get a large dot product
  550. 24:33with the coefficients of the linear function
  551. 24:36that the model represents.
  552. 24:38It also means that when
  553. 24:39we're constructing adversarial examples,
  554. 24:41we need to make sure that the adversarial example procedure
  555. 24:44isn't able to do what happened
  556. 24:46in the top row of this slide here.
  557. 24:48So in the top row of this slide,
  558. 24:49we took the three and we actually
  559. 24:50just changed it into a seven.
  560. 24:52So when the model says that the image
  561. 24:53in the upper right is a seven, it's not a mistake.
  562. 24:56We actually just changed the input class.
  563. 24:59When we build adversarial examples,
  564. 25:00we want to make sure that we're measuring real mistakes.
  565. 25:02If we're experimenters studying
  566. 25:04how easy a network is to fool,
  567. 25:06we want to make sure that we're actually fooling it
  568. 25:08and not just changing the input class.
  569. 25:11And if we're an attacker, we actually want to make sure
  570. 25:13that we're causing misbehavior in the system.
  571. 25:17To do that, when we build adversarial examples,
  572. 25:19we use the maxnorm to constrain the perturbation.
  573. 25:24Basically this says that no pixel can change
  574. 25:26by more than some amount epsilon.
  575. 25:28So the L2 norm can get really big,
  576. 25:30but you can't concentrate all the changes
  577. 25:33for that L2 norm to erase pieces of the digit,
  578. 25:35like in the bottom row here we erased the top of a three.
  579. 25:39One very fast way to build an adversarial example
  580. 25:42is just to take the gradient of the cost
  581. 25:45that you used to train the network
  582. 25:47with respect to the input,
  583. 25:48and then take the sign of that gradient.
  584. 25:51The sign is essentially enforcing the maxnorm constraint.
  585. 25:55You're only allowed to change the input by
  586. 25:58up to epsilon at each pixel,
  587. 26:00so if you just take the sign it tells you
  588. 26:02whether you want to add epsilon or subtract epsilon
  589. 26:04in order to hurt the network.
  590. 26:07You can view this as taking the observation
  591. 26:08that the network is more or less linear,
  592. 26:10as we showed on this slide,
  593. 26:12and using that to motivate
  594. 26:14building a first order Taylor series approximation
  595. 26:17of the neural network's cost.
  596. 26:21And then subject to that Taylor series approximation,
  597. 26:24we want to maximize the cost
  598. 26:26following this maxnorm constraint.
  599. 26:28And that gives us this technique that we call
  600. 26:30the fast gradient sign method.
  601. 26:32If you want to just get your hands dirty
  602. 26:34and start making adversarial examples really quickly,
  603. 26:36or if you have an algorithm where you want to train
  604. 26:38on adversarial examples in the inner loop of learning,
  605. 26:41this method will make adversarial examples for you
  606. 26:43very, very quickly.
  607. 26:45In practice you should also use other methods,
  608. 26:47like Nicholas Carlini's attack based on
  609. 26:50multiple steps of the Adam optimizer,
  610. 26:52to make sure that you have a very strong attack
  611. 26:55that you bring out when you think you have a model
  612. 26:57that might be more powerful.
  613. 26:59A lot of the time people find that they can defeat
  614. 27:02the fast gradient sign method
  615. 27:03and think that they've built a successful defense,
  616. 27:05but then when you bring out a more powerful method
  617. 27:08that takes longer to evaluate,
  618. 27:10they find that they can't overcome
  619. 27:12the more computationally expensive attack.
  620. 27:18I've told you that adversarial examples happen
  621. 27:20because the model is very linear.
  622. 27:22And then I told you that we could
  623. 27:23use this linearity assumption
  624. 27:25to build this attack, the fast gradient sign method.
  625. 27:28This method, when applied to a regular neural network
  626. 27:31that doesn't have any special defenses,
  627. 27:34will get over a 99% attack success rate.
  628. 27:38So that seems to confirm, somewhat,
  629. 27:40this hypothesis that adversarial examples
  630. 27:42come from the model being far too linear
  631. 27:45and extrapolating in linear fashions when it shouldn't.
  632. 27:48Well we can actually go looking for some more evidence.
  633. 27:51My friend David Warde-Farley and I built these maps
  634. 27:54of the decision boundaries of neural networks.
  635. 27:57And we found that they are consistent
  636. 27:58with the linearity hypothesis.
  637. 28:02So the FGSM is that attack method
  638. 28:04that I described in the previous slide,
  639. 28:06where we take the sign of the gradient.
  640. 28:08We'd like to build a map
  641. 28:09of a two-dimensional cross section of input space
  642. 28:13and show which classes are assigned
  643. 28:15to the data at each point.
  644. 28:18In the grid on the right, each different cell,
  645. 28:21each little square within the grid,
  646. 28:23is a map of a CIFAR-10 classifier's decision boundary,
  647. 28:27with each cell corresponding to a different
  648. 28:29CIFAR-10 testing sample.
  649. 28:32On the left I show you a little legend
  650. 28:34where you can understand what each cell means.
  651. 28:37The very center of each cell corresponds to
  652. 28:40the original example from the CIFAR-10 dataset
  653. 28:43with no modification.
  654. 28:45As we move left to right in the cell,
  655. 28:47we're moving in the direction
  656. 28:48of the fast gradient sign method attack.
  657. 28:50So just the sign of the gradient.
  658. 28:53As we move up and down within the cell,
  659. 28:54we're moving in a random direction that's orthogonal to
  660. 28:58the fast gradient sign method direction.
  661. 29:00So we get to see a cross section, a 2D cross section
  662. 29:04of CIFAR-10 decision space.
  663. 29:07At each pixel within this map,
  664. 29:09we plot a color that tells us which class is assigned there.
  665. 29:13We use white pixels to indicate that
  666. 29:15the correct class was chosen,
  667. 29:17and then we used different colors to represent
  668. 29:19all of the other incorrect classes.
  669. 29:21You can see that in nearly all
  670. 29:23of the grid cells on the right,
  671. 29:25roughly the left half of the image is white.
  672. 29:29So roughly the left half of the image
  673. 29:31has been correctly classified.
  674. 29:33As we move to the right, we see that there is usually
  675. 29:36a different color on the right half.
  676. 29:39And the boundaries between these regions
  677. 29:41are approximately linear.
  678. 29:43What's going on here is that the fast gradient sign method
  679. 29:45has identified a direction
  680. 29:47where if we get a large dot product with that direction
  681. 29:50we can get an adversarial example.
  682. 29:52And from this we can see that adversarial examples
  683. 29:54live more or less in linear subspaces.
  684. 29:59When we first discovered adversarial examples,
  685. 30:01we thought that they might live in little tiny pockets.
  686. 30:04In the first paper we actually speculated that
  687. 30:06maybe they're a little bit like the rational numbers,
  688. 30:09hiding out finely tiled among the real numbers,
  689. 30:11with nearly every real number being near a rational number.
  690. 30:15We thought that because we were able to find
  691. 30:17an adversarial example corresponding
  692. 30:18to every clean example that we loaded into the network.
  693. 30:22After doing this further analysis,
  694. 30:23we found that what's happening is that every real example
  695. 30:27is near one of these linear decision boundaries
  696. 30:29where you cross over into an adversarial subspace.
  697. 30:32And once you're in that adversarial subspace,
  698. 30:35all the other points nearby are also adversarial examples
  699. 30:38that will be misclassified.
  700. 30:40This has security implications
  701. 30:42because it means you only need to get the direction right.
  702. 30:46You don't need to find an exact coordinate in space.
  703. 30:48You just need to find a direction
  704. 30:50that has a large dot product with the sign of the gradient.
  705. 30:54And once you move more or less approximately
  706. 30:56in that direction, you can fool the model.
  707. 31:01We also made another cross section
  708. 31:02where after using the left-right axis
  709. 31:05as the fast gradient sign method,
  710. 31:07we looked for a second direction
  711. 31:09that has high dot product with the gradient
  712. 31:11so we could make both axes adversarial.
  713. 31:14And in this case you see that we get
  714. 31:16linear decision boundaries.
  715. 31:18They're now oriented diagonally rather than vertically,
  716. 31:21but you can see that there's actually
  717. 31:23this two-dimensional subspace
  718. 31:24of adversarial examples that we can cross into.
  719. 31:29Finally it's important to remember
  720. 31:30that adversarial examples are not noise.
  721. 31:33You can add a lot of noise to an adversarial example
  722. 31:35and it will stay adversarial.
  723. 31:37You can add a lot of noise to a clean example
  724. 31:39and it will stay clean.
  725. 31:40Here we make random cross sections
  726. 31:42where both axes are randomly chosen directions.
  727. 31:45And you see that on CIFAR-10,
  728. 31:47most of the cells are completely white,
  729. 31:49meaning that they're correctly classified to start with,
  730. 31:51and when you add noise they stay correctly classified.
  731. 31:54We also see that the model makes some mistakes
  732. 31:56because this is the test set.
  733. 31:58And generally if a test example starts out misclassified,
  734. 32:01adding the noise doesn't change it.
  735. 32:03There are a few exceptions where,
  736. 32:05if you look in the third row, third column,
  737. 32:08noise actually can make the model misclassify the example
  738. 32:12for especially large noise values.
  739. 32:14And there's even some where,
  740. 32:17in the top row there's one example you can see where
  741. 32:20the model is misclassifying the test example to start with
  742. 32:23but then noise can change it to be correctly classified.
  743. 32:26For the most part, noise has very little effect
  744. 32:28on the classification decision
  745. 32:31compared to adversarial examples.
  746. 32:33What's going on here is that in high dimensional spaces,
  747. 32:36if you choose some reference vector
  748. 32:38and then you choose a random vector
  749. 32:41in that high dimensional space,
  750. 32:42the random vector will, on average,
  751. 32:45have zero dot product with the reference vector.
  752. 32:49So if you think about making
  753. 32:51a first order Taylor series approximation of your cost,
  754. 32:54and thinking about how your Taylor series approximation
  755. 32:57predicts that random vectors will change your cost.
  756. 33:00You see that random vectors on average
  757. 33:02have no effect on the cost.
  758. 33:04But adversarial examples are chosen to maximize it.
  759. 33:10In these plots we looked in two dimensions.
  760. 33:13More recently, Florian Tramer here at Stanford
  761. 33:16got interested in finding out
  762. 33:17just how many dimensions there are to these subspaces
  763. 33:20where the adversarial examples
  764. 33:22lie in a thick contiguous region.
  765. 33:25And we came up with an algorithm together
  766. 33:28where you actually look for
  767. 33:30several different orthogonal vectors
  768. 33:32that all have a large dot product with the gradient.
  769. 33:35By looking in several different
  770. 33:38orthogonal directions simultaneously,
  771. 33:40we can map out this kind of polytope
  772. 33:42where many different adversarial examples live.
  773. 33:45We found out that this adversarial region
  774. 33:47has on average about 25 dimensions.
  775. 33:51If you look at different examples you'll find
  776. 33:53different numbers of adversarial dimensions.
  777. 33:56But on average on MNIST we found it was about 25.
  778. 33:59So what's interesting here is the dimensionality
  779. 34:02actually tells you something about
  780. 34:04how likely you are to find an adversarial example
  781. 34:06by generating random noise.
  782. 34:09If every direction were adversarial,
  783. 34:12then any change would cause a misclassification.
  784. 34:15If most of the directions were adversarial,
  785. 34:17then random directions would end up being adversarial
  786. 34:20just by accident most of the time.
  787. 34:22And then if there was only one adversarial direction,
  788. 34:25you'd almost never find that direction
  789. 34:28just by adding random noise.
  790. 34:30When there's 25 you have a chance of doing it sometimes.
  791. 34:34Another interesting thing is that different models
  792. 34:36will often misclassify the same adversarial examples.
  793. 34:39The subspace dimensionality of the adversarial subspace
  794. 34:43relates to that transfer property.
  795. 34:46The larger the dimensionality of the subspace,
  796. 34:48the more likely it is that the subspaces
  797. 34:50for two models will intersect.
  798. 34:52So if you have two different models
  799. 34:55that have a very large adversarial subspace,
  800. 34:57you know that you can probably transfer
  801. 34:58adversarial examples from one to the other.
  802. 35:01But if the adversarial subspace is very small,
  803. 35:03then unless there's some kind of really systematic effect
  804. 35:06forcing them to share exactly the same subspace,
  805. 35:09it seems less likely that you'll be able to transfer
  806. 35:11examples just due to the subspaces randomly aligning.
  807. 35:17A lot of the time in the adversarial example
  808. 35:20research community,
  809. 35:21we refer back to the story of Clever Hans.
  810. 35:25This comes from an essay by Bob Sturm called
  811. 35:28Clever Hans, Clever Algorithms.
  812. 35:30Because Clever Hans is a pretty good metaphor
  813. 35:32for what's happening with machine learning algorithms.
  814. 35:35So Clever Hans was a horse that lived in the early 1900s.
  815. 35:39His owner trained him to do arithmetic problems.
  816. 35:43So you could ask him, "Clever Hans,
  817. 35:45"what's two plus one?"
  818. 35:47And he would answer by tapping his hoof.
  819. 35:52And after the third tap, everybody would start
  820. 35:54cheering and clapping and looking excited
  821. 35:56because he'd actually done an arithmetic problem.
  822. 35:59Well it turned out that
  823. 36:01he hadn't actually learned to do arithmetic.
  824. 36:03But it was actually pretty hard to figure out
  825. 36:05what was going on.
  826. 36:06His owner was not trying to defraud anybody,
  827. 36:10his owner actually believed he could do arithmetic.
  828. 36:13And presumably Clever Hans himself
  829. 36:15was not trying to trick anybody.
  830. 36:18But eventually a psychologist examined him
  831. 36:20and found that if he was put in a room alone
  832. 36:23without an audience,
  833. 36:25and the person asking the questions wore a mask,
  834. 36:29he couldn't figure out when to stop tapping.
  835. 36:31You'd ask him, "Clever Hans,
  836. 36:32"what's one plus one?"
  837. 36:33And he'd just [knocking]
  838. 36:38keep staring at your face, waiting for you
  839. 36:40to give him some sign that he was done tapping.
  840. 36:42So everybody in this situation
  841. 36:44was trying to do the right thing.
  842. 36:46Clever Hans was trying to do whatever it took
  843. 36:48to get the apple that his owner would give him
  844. 36:51when he answered an arithmetic problem.
  845. 36:53His owner did his best to train him correctly
  846. 36:56with real arithmetic questions
  847. 36:57and real rewards for correct answers.
  848. 37:00And what happened was that Clever Hans
  849. 37:03inadvertently focused on the wrong cue.
  850. 37:07He found this cue of people's social reactions
  851. 37:09that could reliably help him solve the problem,
  852. 37:12but then it didn't generalize to a test set
  853. 37:15where you intentionally took that cue away.
  854. 37:18It did generalize to a naturally occurring test set,
  855. 37:21where he had an audience.
  856. 37:22So that's more or less what's happening
  857. 37:24with machine learning algorithms.
  858. 37:26They've found these very linear patterns
  859. 37:28that can fit the training data,
  860. 37:30and these linear patterns even generalize to the test data.
  861. 37:34They've learned to handle any example that comes from
  862. 37:36the same distribution as their training data.
  863. 37:40But then if you shift the distribution
  864. 37:42that you test them on,
  865. 37:43if a malicious adversary actually creates examples
  866. 37:46that are intended to fool them,
  867. 37:48they're very easily fooled.
  868. 37:51In fact we find that modern machine learning algorithms
  869. 37:54are wrong almost everywhere.
  870. 37:56We tend to think of them as being correct most of the time,
  871. 37:59because when we run them on naturally occurring inputs
  872. 38:02they achieve very high accuracy percentages.
  873. 38:06But if we look instead of as the percentage
  874. 38:08of samples from an IID test set,
  875. 38:12if we look at the percentage of the space in RN
  876. 38:15that is correctly classified,
  877. 38:17we find that they misclassify almost everything
  878. 38:20and they behave reasonably only on a very thin manifold
  879. 38:24surrounding the data that we train them on.
  880. 38:27In this plot, I show you several different examples
  881. 38:30of Gaussian noise
  882. 38:32that I've run through a CIFAR-10 classifier.
  883. 38:35Everywhere that there is a pink box,
  884. 38:37the classifier thinks that there is something
  885. 38:39rather than nothing.
  886. 38:40I'll come back to what that means in a second.
  887. 38:43Everywhere that there is a yellow box,
  888. 38:45one step of the fast gradient sign method
  889. 38:47was able to persuade the model that it was looking
  890. 38:50specifically at an airplane.
  891. 38:52I chose the airplane class
  892. 38:53because it was the one with the lowest success rate.
  893. 38:56It had about a 25% success rate.
  894. 38:58That means an attacker would need four chances
  895. 39:01to get noise recognized as an airplane on this model.
  896. 39:06An interesting thing, and appropriate enough
  897. 39:08given the story of Clever Hans,
  898. 39:09is that this model found that about 70% of RN
  899. 39:12was classified as a horse.
  900. 39:17So I mentioned that this model will say
  901. 39:20that noise is something rather than nothing.
  902. 39:22And it's actually kind of important to think about
  903. 39:24how we evaluate that.
  904. 39:26If you have a softmax classifier,
  905. 39:28it has to give you a distribution
  906. 39:30over the n different classes that you train it on.
  907. 39:34So there's a few ways that you can argue
  908. 39:35that the model is telling you
  909. 39:37that there's something rather than nothing.
  910. 39:39One is you can say, if it assigns something like 90%
  911. 39:42to one particular class,
  912. 39:43that seems to be voting for that class being there.
  913. 39:46We'd much rather see it give us
  914. 39:47something like a uniform distribution saying
  915. 39:50this noise doesn't look like anything in the training set
  916. 39:52so it's equally likely to be a horse or a car.
  917. 39:56And that's not what the model does.
  918. 39:58It'll say, this is very definitely a horse.
  919. 40:01Another thing that you can do is you can replace
  920. 40:03the last layer of the model.
  921. 40:05For example, you can use a sigmoid output for each class.
  922. 40:10And then the model is actually capable of telling you
  923. 40:11that any subset of classes is present.
  924. 40:14It could actually tell you that an image
  925. 40:15is both a horse and a car.
  926. 40:17And what we would like it to do for the noise
  927. 40:19is tell us that none of the classes is present,
  928. 40:21that all of the sigmoids should have a value
  929. 40:23of less than 1/2.
  930. 40:25And 1/2 isn't even particularly a low threshold.
  931. 40:29We could reasonably expect that all of the sigmoids would be
  932. 40:32less than 0.01 for such a defective input as this.
  933. 40:35But what we find instead is that the sigmoids
  934. 40:38tend to have at least one class present
  935. 40:40just when we run Gaussian noise
  936. 40:42of sufficient norm through the model.
  937. 40:48We've also found that we can do adversarial examples
  938. 40:50for reinforcement learning.
  939. 40:51And there's a video for this.
  940. 40:53I'll upload the slides after the talk
  941. 40:54and you can follow the link.
  942. 40:56Unfortunately I wasn't able to get the WiFi to work
  943. 40:58so I can't show you the video animated.
  944. 41:00But I can describe basically what's going on
  945. 41:01from this still here.
  946. 41:05There's a game Seaquest on Atari
  947. 41:08where you can train reinforcement learning agents
  948. 41:09to play that game.
  949. 41:11And you can take the raw input pixels
  950. 41:14and you can take the fast gradient sign method
  951. 41:18or other attacks that use other norms besides the max norm,
  952. 41:21and compute perturbations that are intended
  953. 41:24to change the action that the policy would select.
  954. 41:27So the reinforcement learning policy,
  955. 41:29you can think of it as just being like a classifier
  956. 41:31that looks at a frame.
  957. 41:33And instead of categorizing the input
  958. 41:35into a particular category,
  959. 41:37it gives you a softmax distribution over actions to take.
  960. 41:40So if we just take that and say that the most likely action
  961. 41:43should have its accuracy be decreased by the adversary.
  962. 41:47Sorry, to have its probability
  963. 41:49be decreased by the adversary,
  964. 41:51you'll get these perturbations of input frames
  965. 41:53that you can then apply and cause the agent
  966. 41:55to play different actions than it would have otherwise.
  967. 41:58And using this you can make the agent
  968. 42:00play Seaquest very, very badly.
  969. 42:03It's maybe not the most interesting possible thing.
  970. 42:06What we'd really like is an environment
  971. 42:07where there are many different reward functions available
  972. 42:09for us to study.
  973. 42:11So for example, if you had a robot
  974. 42:15that was intended to cook scrambled eggs,
  975. 42:17and you had a reward function measuring
  976. 42:18how well it's cooking scrambled eggs,
  977. 42:20and you had another reward function
  978. 42:22measuring how well it's cooking chocolate cake,
  979. 42:25it would be really interesting if we could make
  980. 42:27adversarial examples that cause the robot
  981. 42:29to make a chocolate cake
  982. 42:31when the user intended for it to make scrambled eggs.
  983. 42:35That's because it's very difficult to succeed at something
  984. 42:37and it's relatively straightforward to make a system fail.
  985. 42:40So right now, adversarial examples for RL
  986. 42:42are very good at showing that we can make RL agents fail.
  987. 42:45But we haven't yet been able to hijack them
  988. 42:47and make them do a complicated task
  989. 42:49that's different from what their owner intended.
  990. 42:51Seems like it's one of the next steps
  991. 42:53in adversarial example research though.
  992. 42:58If we look at high-dimension linear models,
  993. 43:01we can actually see that a lot of this
  994. 43:02is very simple and straightforward.
  995. 43:04Here we have a logistic regression model
  996. 43:07that classifies sevens and threes.
  997. 43:10So the whole model can be described just by a weight vector
  998. 43:13and a single scalar bias term.
  999. 43:16We don't really need to see the bias term for this exercise.
  1000. 43:20If you look on the left I've plotted the weights
  1001. 43:22that we used to discriminate sevens and threes.
  1002. 43:24The weights should look a little bit like the difference
  1003. 43:27between the average seven and the average three.
  1004. 43:30And then down at the bottom we've taken
  1005. 43:31the sign of the weights.
  1006. 43:33So the gradient for a logistic regression model
  1007. 43:35is going to be proportional to the weights.
  1008. 43:38And then the sign of the weights gives you
  1009. 43:41essentially the sign of the gradient.
  1010. 43:43So we can do the fast gradient sign method
  1011. 43:46to attack this model just by looking at its weights.
  1012. 43:49In the examples in the panel
  1013. 43:52that's the second column from the left
  1014. 43:54we can see clean examples.
  1015. 43:55And then on the right we've just added or subtracted
  1016. 43:58this image of the sign of the weights off of them.
  1017. 44:00To you and me as human observers,
  1018. 44:03the sign of the weights is just like garbage
  1019. 44:06that's in the background,
  1020. 44:08and we more or less filter it out.
  1021. 44:09It doesn't look particularly interesting to us.
  1022. 44:11It doesn't grab our attention.
  1023. 44:14To the logistic regression model
  1024. 44:16this image of the sign of the weights
  1025. 44:17is the most salient thing
  1026. 44:20that could ever appear in the image.
  1027. 44:22When it's positive it looks like
  1028. 44:24the world's most quintessential seven.
  1029. 44:26When it's negative it looks like
  1030. 44:27the world's most quintessential three.
  1031. 44:29And so the model makes its decision
  1032. 44:31almost entirely based on this perturbation
  1033. 44:33we added to the image, rather than on the background.
  1034. 44:38You could also take this same procedure,
  1035. 44:40and my colleague Andrej at OpenAI showed how you can
  1036. 44:45modify the image on ImageNet using this same approach,
  1037. 44:49and turn this goldfish into a daisy.
  1038. 44:51Because ImageNet is much higher dimensional,
  1039. 44:53you don't need to use quite as large of a coefficient
  1040. 44:56on the image of the weights.
  1041. 44:58So we can make a more persuasive fooling attack.
  1042. 45:03You can see that this same image of the weights,
  1043. 45:05when applied to any different input image,
  1044. 45:08will actually reliably cause a misclassification.
  1045. 45:12What's going on is that there are many different classes,
  1046. 45:14and it means that if you choose the weights
  1047. 45:18for any particular class,
  1048. 45:20it's very unlikely that a new test image
  1049. 45:23will belong to that class.
  1050. 45:25So on ImageNet, if we're using
  1051. 45:27the weights for the daisy class,
  1052. 45:29and there are 1,000 different classes,
  1053. 45:31then we have about a 99.9% chance
  1054. 45:33that a test image will not be a daisy.
  1055. 45:36If we then go ahead and add the weights
  1056. 45:37for the daisy class to that image,
  1057. 45:39then we get a daisy, and because that's not
  1058. 45:41the correct class, it's a misclassification.
  1059. 45:45So there's a paper at CVPR this year
  1060. 45:47called Universal Adversarial Perturbations
  1061. 45:48that expands a lot more on this observation
  1062. 45:51that we had going back in 2014.
  1063. 45:53But basically these weight vectors,
  1064. 45:56when applied to many different images,
  1065. 45:59can cause misclassification in all of them.
  1066. 46:04I've spent a lot of time telling you
  1067. 46:06that these linear models are just terrible,
  1068. 46:08and at some point you've probably been hoping
  1069. 46:11I would give you some sort of a control experiment
  1070. 46:13to convince you that there's another model
  1071. 46:15that's not terrible.
  1072. 46:16So it turns out that some quadratic models
  1073. 46:19actually perform really well.
  1074. 46:21In particular a shallow RBF network
  1075. 46:23is able to resist adversarial perturbations very well.
  1076. 46:27Earlier I showed you an animation
  1077. 46:29where I took a nine and I turned it into
  1078. 46:30a zero, one, two, and so on,
  1079. 46:32without really changing its appearance at all.
  1080. 46:34And I was able to fool
  1081. 46:36a linear softmax regression classifier.
  1082. 46:39Here I've got an RBF network
  1083. 46:40where it outputs a separate probability
  1084. 46:43of each class being absent or present,
  1085. 46:45and that probability is given by e to the negative square
  1086. 46:51of the difference between a template image
  1087. 46:53and the input image.
  1088. 46:55And if we actually follow the gradient of this classifier,
  1089. 46:59it does actually turn the image into
  1090. 47:01a zero, a one, a two, a three, and so on,
  1091. 47:04and we can actually recognize those changes.
  1092. 47:07The problem is, this classifier does not get
  1093. 47:09very good accuracy on the training set.
  1094. 47:12It's a shallow model.
  1095. 47:13It's basically just a template matcher.
  1096. 47:15It is literally a template matcher.
  1097. 47:17And if you try to make it more sophisticated
  1098. 47:20by making it deeper,
  1099. 47:22it turns out that the gradient of these RBF units is zero,
  1100. 47:27or very near zero, throughout most of RN.
  1101. 47:30So they're extremely difficult to train,
  1102. 47:32even with batch normalization and methods like that.
  1103. 47:36I haven't managed to train a deep RBF network yet.
  1104. 47:39But I think if somebody comes up with better hyperparameters
  1105. 47:42or a new, more powerful optimization algorithm,
  1106. 47:46it might be possible to solve
  1107. 47:47the adversarial example problem
  1108. 47:49by training a deep RBF network
  1109. 47:51where the model is so nonlinear and has such wide flat areas
  1110. 47:55that the adversary is not able to push the cost uphill
  1111. 47:59just by making small changes to the model's input.
  1112. 48:05One of the things that's the most alarming
  1113. 48:06about adversarial examples
  1114. 48:08is that they generalize from one dataset to another
  1115. 48:11and one model to another.
  1116. 48:13Here I've trained two different models
  1117. 48:15on two different training sets.
  1118. 48:17The training sets are tiny in both cases.
  1119. 48:20It's just MNIST three versus seven classification,
  1120. 48:23and this is really just for the purpose of making a slide.
  1121. 48:26If you train a logistic regression model
  1122. 48:29on the digits shown in the left panel,
  1123. 48:32you get the weights shown on the left in the lower panel.
  1124. 48:35If you train a logistic regression model
  1125. 48:37on the digits shown in the upper right,
  1126. 48:39you get the weights shown on the right in the lower panel.
  1127. 48:42So you've got two different training sets
  1128. 48:44and we learn weight vectors that look
  1129. 48:45very similar to each other.
  1130. 48:47That's just because machine learning algorithms generalize.
  1131. 48:50You want them to learn a function that's
  1132. 48:51somewhat independent of the data that you train them on.
  1133. 48:54It shouldn't matter which particular
  1134. 48:55training examples you choose.
  1135. 48:57If you want to generalize
  1136. 48:58from the training set to the test set,
  1137. 49:00you've also got to expect that different training sets
  1138. 49:02will give you more or less the same result.
  1139. 49:05And that means that because they've learned
  1140. 49:06more or less similar functions,
  1141. 49:08they're vulnerable to similar adversarial examples.
  1142. 49:13An adversary can compute an image that fools one
  1143. 49:15and use it to fool the other.
  1144. 49:18In fact we can actually go ahead and measure
  1145. 49:20the transfer rate between
  1146. 49:22several different machine learning techniques,
  1147. 49:24not just different data sets.
  1148. 49:27Nicolas Papernot and his collaborators
  1149. 49:28have spent a lot of time exploring
  1150. 49:30this transferability effect.
  1151. 49:32And they found that for example,
  1152. 49:35logistic regression makes adversarial examples
  1153. 49:38that transfer to decision trees with 87.4% probability.
  1154. 49:44Wherever you see dark squares in this matrix,
  1155. 49:48that shows that there's a high amount of transfer.
  1156. 49:50That means that it's very possible for an attacker
  1157. 49:53using the model on the left
  1158. 49:56to create adversarial examples for the model on the right.
  1159. 50:01The procedure overall is that,
  1160. 50:03suppose the attacker wants to fool a model
  1161. 50:05that they don't actually have access to.
  1162. 50:07They don't know the architecture that's used
  1163. 50:10to train the model.
  1164. 50:11They may not even know which algorithm is being used.
  1165. 50:13They may not know whether they're attacking
  1166. 50:15a decision tree or a deep neural net.
  1167. 50:17And they also don't know the parameters
  1168. 50:20of the model that they're going to attack.
  1169. 50:23So what they can do is train their own model
  1170. 50:26that they'll use to build the attack.
  1171. 50:30There's two different ways you can train your own model.
  1172. 50:32One is you can label your own training set
  1173. 50:33for the same task that you want to attack.
  1174. 50:36Say that somebody is using an ImageNet classifier,
  1175. 50:39and for whatever reason you don't have access to ImageNet,
  1176. 50:42you can take your own photos and label them,
  1177. 50:44train your own object recognizer.
  1178. 50:46It's going to share adversarial examples
  1179. 50:48with an ImageNet model.
  1180. 50:50The other thing you can do is,
  1181. 50:52say that you can't afford to gather your own training set.
  1182. 50:55What you can do instead is if you can get
  1183. 50:57limited access to the model
  1184. 50:59where you just have the ability to send inputs to the model
  1185. 51:02and observe its outputs,
  1186. 51:03then you can send those inputs, observe the outputs,
  1187. 51:06and use those as your training set.
  1188. 51:09This'll work even if the output
  1189. 51:11that you get from the target model
  1190. 51:12is only the class label that it chooses.
  1191. 51:15A lot of people read this and assume that
  1192. 51:17you need to have access
  1193. 51:19to all the probability values it outputs.
  1194. 51:21But even just the class labels are sufficient.
  1195. 51:24So once you've used one of these two methods,
  1196. 51:26either gather your own training set
  1197. 51:28or observing the outputs of a target model,
  1198. 51:31you can train your own model
  1199. 51:32and then make adversarial examples for your model.
  1200. 51:36Those adversarial examples are very likely to transfer
  1201. 51:38and affect the target model.
  1202. 51:41So you can then go and send those out and fool it,
  1203. 51:43even if you didn't have access to it directly.
  1204. 51:48We've also measured the transferability
  1205. 51:50across different data sets,
  1206. 51:52and for most models we find that they're
  1207. 51:54kind of in an intermediate zone
  1208. 51:56where different data sets will result
  1209. 51:58in a transfer rate of, like, 60% to 80%.
  1210. 52:01There's a few models like SVMs that are very data dependent
  1211. 52:04because SVMs end up focusing on a very small subset
  1212. 52:08of the training data to form their final decision boundary.
  1213. 52:10But most models that we care about
  1214. 52:12are somewhere in the intermediate zone.
  1215. 52:17Now that's just assuming that you rely
  1216. 52:19on the transfer happening naturally.
  1217. 52:22You make an adversarial example
  1218. 52:23and you hope that it will transfer to your target.
  1219. 52:26What if you do something to stack the deck in your favor
  1220. 52:30and improve the odds that you'll get
  1221. 52:33your adversarial examples to transfer?
  1222. 52:35Dawn Song's group at UC Berkeley studied this.
  1223. 52:38They found that if they take an ensemble of different models
  1224. 52:43and they use gradient descent to search for
  1225. 52:46an adversarial example that will fool
  1226. 52:48every member of their ensemble,
  1227. 52:50then it's extremely likely that it will transfer
  1228. 52:53and fool a new machine learning model.
  1229. 52:56So if you have an ensemble of five models,
  1230. 52:59you can get it to the point where
  1231. 53:00there's essentially a 100% chance
  1232. 53:02that you'll fool a sixth model
  1233. 53:04out of the set of models that they compared.
  1234. 53:07They looked at things like ResNets of different depths,
  1235. 53:09VGG, and GoogLeNet.
  1236. 53:12So in the labels for each of the different rows
  1237. 53:16you can see that they made ensembles that lacked
  1238. 53:18each of these different models,
  1239. 53:19and then they would test it on the different target models.
  1240. 53:23So like if you make an ensemble that omits GoogLeNet,
  1241. 53:28you have only about a 5% chance of GoogLeNet
  1242. 53:32correctly classifying the adversarial example
  1243. 53:34you make for that ensemble.
  1244. 53:37If you make an ensemble that omits ResNet-152,
  1245. 53:40in their experiments they found that
  1246. 53:42there was a 0% chance of ResNet-152 resisting that attack.
  1247. 53:48That probably indicates they should have run
  1248. 53:50some more adversarial examples
  1249. 53:52until they found a non-zero success rate,
  1250. 53:54but it does show that the attack is very powerful.
  1251. 53:57And then when you go look into
  1252. 53:59intentionally cause the transfer effect,
  1253. 54:01you can really make it quite strong.
  1254. 54:05A lot of people often ask me if the human brain
  1255. 54:08is vulnerable to adversarial examples.
  1256. 54:10And for this lecture I can't use copyrighted material,
  1257. 54:14but there's some really hilarious things on the Internet
  1258. 54:17if you go looking for, like,
  1259. 54:21the fake CAPTCHA with images of Mark Hamill,
  1260. 54:23you'll find something that my perception system
  1261. 54:27definitely can't handle.
  1262. 54:29So here's another one that's actually published
  1263. 54:31with a license where I was confident I'm allowed to use it.
  1264. 54:35You can look at this image of different circles here,
  1265. 54:38and they appear to be intertwined spirals.
  1266. 54:42But in fact they are concentric circles.
  1267. 54:45The orientation of the edges of the squares
  1268. 54:47is interfering with the edge detectors in your brain,
  1269. 54:51making it look like the circles are spiraling.
  1270. 54:55So you can think of these optical illusions
  1271. 54:57as being adversarial examples in the human brain.
  1272. 54:59What's interesting is that we don't seem to share
  1273. 55:01many adversarial examples in common
  1274. 55:03with machine learning models.
  1275. 55:05Adversarial examples transfer extremely reliably
  1276. 55:08between different machine learning models,
  1277. 55:09especially if you use that ensemble trick
  1278. 55:11that was developed at UC Berkeley.
  1279. 55:15But those adversarial examples don't fool us.
  1280. 55:18It tells us that we must be using
  1281. 55:20a very different algorithm or model family
  1282. 55:22than current convolutional networks.
  1283. 55:25We don't really know what the difference is yet,
  1284. 55:27but it would be very interesting to figure that out.
  1285. 55:30It seems to suggest that studying adversarial examples
  1286. 55:32could tell us how to significantly improve
  1287. 55:35our existing machine learning models.
  1288. 55:37Even if you don't care about having an adversary,
  1289. 55:40we might figure out something or other about
  1290. 55:43how to make machine learning algorithms
  1291. 55:45deal with ambiguity and unexpected inputs
  1292. 55:48more like a human does.
  1293. 55:52If we actually want to go out and do attacks in practice,
  1294. 55:55there's started to be a body of research on this subject.
  1295. 56:00Nicolas Papernot showed that he could use
  1296. 56:03the transfer effect to fool classifiers
  1297. 56:05hosted by MetaMind, Amazon, and Google.
  1298. 56:09So these are all just different machine learning APIs
  1299. 56:11where you can upload a dataset
  1300. 56:13and the API will train the model for you.
  1301. 56:16And then you don't actually know, in most cases,
  1302. 56:19which model is trained for you.
  1303. 56:21You don't have access to its weights or anything like that.
  1304. 56:23So Nicolas would train his own copy of the model
  1305. 56:26using the API,
  1306. 56:27and then build a model on his own personal desktop
  1307. 56:31where he could fool the API hosted model.
  1308. 56:34Later, Berkeley showed you could fool Clarifai in this way.
  1309. 56:36Yeah?
  1310. 56:37- [Man] What did you mean when you said
  1311. 56:39machine having adversarial models don't generally fool us?
  1312. 56:41Because I thought that was part of the point
  1313. 56:43that we generally do machine-generated adversarial models
  1314. 56:46where just a few pixels change.
  1315. 56:48- Oh, so if we look at, for example,
  1316. 56:53like this picture of the panda.
  1317. 56:55To us it looks like a panda.
  1318. 56:56To most machine learning models it looks like a gibbon.
  1319. 56:59And so this change isn't interfering with our brains,
  1320. 57:02but it fools reliably with lots of different
  1321. 57:04machine learning models.
  1322. 57:08I saw somebody actually took this image of the perturbation
  1323. 57:12out of our paper, and they pasted it
  1324. 57:15on their Facebook profile picture
  1325. 57:17to see if it could interfere with Facebook recognizing them.
  1326. 57:20And they said that it did.
  1327. 57:22I don't think that Facebook has a gibbon tag though,
  1328. 57:25so we don't know if they managed to
  1329. 57:29make it think that they were a gibbon.
  1330. 57:34And one of the other things that you can do
  1331. 57:35that's of fairly high practical significance
  1332. 57:39is you can actually fool malware detectors.
  1333. 57:42Catherine Gross at the University of Saarland
  1334. 57:44wrote a paper about this.
  1335. 57:45And there's starting to be a few others.
  1336. 57:47There's a model called MalGAN that actually uses a GAN
  1337. 57:50to generate adversarial examples for malware detectors.
  1338. 57:54Another thing that matters a lot if you are interested
  1339. 57:57in using these attacks in the real world
  1340. 57:58and defending against them in the real world
  1341. 58:00is that a lot of the time you don't actually
  1342. 58:02have access to the digital input to a model.
  1343. 58:06If you're interested in the perception system
  1344. 58:09for a self-driving car or a robot,
  1345. 58:11you probably don't get to actually write to the buffer
  1346. 58:14on the robot itself.
  1347. 58:15You just get to show the robot objects
  1348. 58:18that it can see through a camera lens.
  1349. 58:20So my colleague Alexey Kurakin and Samy Bengio and I
  1350. 58:24wrote a paper where we studied if we can actually fool
  1351. 58:27an object recognition system running on a phone,
  1352. 58:30where it perceives the world through a camera.
  1353. 58:33Our methodology was really straightforward.
  1354. 58:35We just printed out several pictures
  1355. 58:36of adversarial examples.
  1356. 58:38And we found that the object recognition system
  1357. 58:41run by the camera was fooled by them.
  1358. 58:44The system on the camera is actually different
  1359. 58:46from the model that we used
  1360. 58:47to generate the adversarial examples.
  1361. 58:49So we're showing not just transfer across
  1362. 58:53the changes that happen when you use the camera,
  1363. 58:55we're also showing that those transfer across
  1364. 58:58the model that you use.
  1365. 59:00So the attacker could conceivably fool
  1366. 59:02a system that's deployed in a physical agent,
  1367. 59:05even if they don't have access to the model on that agent
  1368. 59:07and even if they can't interface directly with the agent
  1369. 59:11but just subtly modify
  1370. 59:15objects that it can see in its environment.
  1371. 59:19Yeah?
  1372. 59:20- [Man] Why does the,
  1373. 59:22for the low quality camera image noise
  1374. 59:24not affect the adversarial example?
  1375. 59:26Because that's what one would expect.
  1376. 59:28- Yeah, so I think a lot of that
  1377. 59:30comes back to the maps that I showed earlier.
  1378. 59:34If you cross over the boundary into the realm
  1379. 59:36of adversarial examples,
  1380. 59:38they occupy a pretty wide space
  1381. 59:40and they're very densely packed in there.
  1382. 59:43So if you jostle around a little bit,
  1383. 59:45you're not going to recover from the adversarial attack.
  1384. 59:48If the camera noise, somehow or other,
  1385. 59:50was aligned with the negative gradient of the cost,
  1386. 59:53then the camera could take a gradient descent step downhill
  1387. 59:57and rescue you from the uphill step that the adversary took.
  1388. 1:00:01But probably the camera's taking more or less
  1389. 1:00:03something that you could model as a random direction.
  1390. 1:00:06Like clearly when you use the camera more than once
  1391. 1:00:09it's going to do the same thing each time,
  1392. 1:00:11but from the point of view of how that direction
  1393. 1:00:15relates to the image classification problem,
  1394. 1:00:18it's more or less a random variable that you sample once.
  1395. 1:00:22And it seems unlikely to align exactly
  1396. 1:00:25with the normal to this class boundary.
  1397. 1:00:33There's a lot of different defenses that we'd like to build.
  1398. 1:00:36And it's a little bit disappointing
  1399. 1:00:39that I'm mostly here to tell you about attacks.
  1400. 1:00:41I'd like to tell you how to make your systems more robust.
  1401. 1:00:44But basically every attack we've tried
  1402. 1:00:47has failed pretty badly.
  1403. 1:00:49And in fact, even when people have published
  1404. 1:00:52that they successfully defended.
  1405. 1:00:55Well, there's been several papers on arXiv
  1406. 1:00:57over the last several months.
  1407. 1:00:59Nicholas Carlini at Berkeley just released a paper
  1408. 1:01:02where he shows that 10 of those defenses are broken.
  1409. 1:01:07So this is a really, really hard problem.
  1410. 1:01:09You can't just make it go away by using
  1411. 1:01:11traditional regularization techniques.
  1412. 1:01:15Particular, generative models are not enough
  1413. 1:01:18to solve the problem.
  1414. 1:01:19A lot of people say, "Oh the problem that's going on here
  1415. 1:01:21"is you don't know anything about the distribution
  1416. 1:01:23"over the input pixels.
  1417. 1:01:25"If you could just tell
  1418. 1:01:26"whether the input is realistic or not
  1419. 1:01:28"then you'd be able to resist it."
  1420. 1:01:31It turns out that what's going on here is
  1421. 1:01:33what matters more than getting the right distributions
  1422. 1:01:36over the inputs x,
  1423. 1:01:37is getting the right posterior distribution
  1424. 1:01:39over the class of labels y given inputs x.
  1425. 1:01:42So just using a generative model
  1426. 1:01:44is not enough to solve the problem.
  1427. 1:01:46I think a very carefully designed generative model
  1428. 1:01:49could possibly do it.
  1429. 1:01:51Here I show two different modes of a bimodal distribution,
  1430. 1:01:54and we have two different generative models
  1431. 1:01:56that try to capture these modes.
  1432. 1:01:58On the left we have a mixture of two Gaussians.
  1433. 1:02:01On the right we have a mixture of two Laplacians.
  1434. 1:02:04You can not really tell the difference visually
  1435. 1:02:06between the distribution they impose over x,
  1436. 1:02:09and the difference in the likelihood they assign
  1437. 1:02:11to the training data is negligible.
  1438. 1:02:13But the posterior distribution they assign over classes
  1439. 1:02:16is extremely different.
  1440. 1:02:17On the left we get a logistic regression classifier
  1441. 1:02:20that has very high confidence
  1442. 1:02:22out in the tails of the distribution
  1443. 1:02:25where there is never any training data.
  1444. 1:02:27On the right, with the Laplacian distribution,
  1445. 1:02:29we level off to more or less 50-50.
  1446. 1:02:33Yeah?
  1447. 1:02:33[speaker drowned out]
  1448. 1:02:44The issue is that it's a nonstationary distribution.
  1449. 1:02:46So if you train it to recognize
  1450. 1:02:48one kind of adversarial example,
  1451. 1:02:49then it will become vulnerable to another kind
  1452. 1:02:52that's designed to fool its detector.
  1453. 1:02:55That's one of the category of defenses that Nicholas broke
  1454. 1:02:59in his latest paper that he put out.
  1455. 1:03:04So here basically the choice of exactly
  1456. 1:03:07the family of generative model has a big effect
  1457. 1:03:09in whether the posterior becomes deterministic or uniform,
  1458. 1:03:14as the model extrapolates.
  1459. 1:03:17And if we could design a really rich, deep generative model
  1460. 1:03:21that can generate realistic ImageNet images
  1461. 1:03:24and also correctly calculate its posterior distribution,
  1462. 1:03:28then maybe something like this approach could work.
  1463. 1:03:31But at the moment it's really difficult to get
  1464. 1:03:33any of those probabilistic calculations correct.
  1465. 1:03:36And what usually happens is,
  1466. 1:03:38somewhere or other we make an approximation
  1467. 1:03:40that causes the posterior distribution
  1468. 1:03:42to extrapolate very linearly again.
  1469. 1:03:45It's been a difficult engineering challenge
  1470. 1:03:48to build generative models
  1471. 1:03:50that actually capture these distributions accurately.
  1472. 1:03:55The universal approximator theorem tells us that
  1473. 1:03:58whatever shape we would like
  1474. 1:04:00our classification function to have,
  1475. 1:04:02a neural net that's big enough
  1476. 1:04:04ought to be able to represent it.
  1477. 1:04:06It's an open question whether we can train the neural net
  1478. 1:04:08to have that function,
  1479. 1:04:09but we know that we should be able to
  1480. 1:04:11at least give the right shape.
  1481. 1:04:13So so far we've been getting neural nets
  1482. 1:04:15that give us these very linear decision functions,
  1483. 1:04:18and we'd like to get something
  1484. 1:04:19that looks a little bit more like a step function.
  1485. 1:04:21So what if we actually just train on adversarial examples?
  1486. 1:04:25For every input x in the training set,
  1487. 1:04:27we also say we want you to train x plus an attack to map
  1488. 1:04:31to the same class label as the original.
  1489. 1:04:34It turns out that this sort of works.
  1490. 1:04:37You can generally resist
  1491. 1:04:39the same kind of attack that you train on.
  1492. 1:04:41And an important consideration
  1493. 1:04:43is making sure that you could run your attack very quickly
  1494. 1:04:46so that you can train on lots of examples.
  1495. 1:04:48So here the green curve at the very top,
  1496. 1:04:51the one that doesn't really descend much at all,
  1497. 1:04:53that's the test set error on adversarial examples
  1498. 1:04:56if you train on clean examples only.
  1499. 1:05:00The cyan curve that descends more or less diagonally
  1500. 1:05:03through the middle of the plot,
  1501. 1:05:05that's the tester on adversarial examples
  1502. 1:05:07if you train on adversarial examples.
  1503. 1:05:10You can see that it does actually reduce significantly.
  1504. 1:05:13It gets down to a little bit less than 1% error.
  1505. 1:05:16And the important thing to keep in mind here is that
  1506. 1:05:20this is fast gradient sign method adversarial examples.
  1507. 1:05:23It's much harder to resist
  1508. 1:05:24iterative multi-step adversarial examples
  1509. 1:05:27where you run an optimizer for a long time
  1510. 1:05:29searching for a vulnerability.
  1511. 1:05:31And another thing to keep in mind
  1512. 1:05:33is that we're testing on
  1513. 1:05:34the same kind of adversarial examples that we train on.
  1514. 1:05:36It's harder to generalize
  1515. 1:05:37from one optimization algorithm to another.
  1516. 1:05:42By comparison, if you look at
  1517. 1:05:46what happens on clean examples,
  1518. 1:05:48the blue curve shows what happens
  1519. 1:05:50on the clean test set error rate
  1520. 1:05:53if you train only on clean examples.
  1521. 1:05:55The red curve shows what happens
  1522. 1:05:57if you train on both clean and adversarial examples.
  1523. 1:06:01We see that the red curve
  1524. 1:06:02actually drops lower than the blue curve.
  1525. 1:06:04So on this task, training on adversarial examples
  1526. 1:06:07actually helped us to do the original task better.
  1527. 1:06:10This is because in the original task we were overfitting.
  1528. 1:06:12Training on adversarial examples is good regularizer.
  1529. 1:06:15If you're overfitting it can make you overfit less.
  1530. 1:06:18If you're underfitting it'll just make you underfit worse.
  1531. 1:06:21Other kinds of models besides deep neural nets
  1532. 1:06:24don't benefit as much from adversarial training.
  1533. 1:06:27So when we started this whole topic of study
  1534. 1:06:29we thought that deep neural nets
  1535. 1:06:30might be uniquely vulnerable to adversarial examples.
  1536. 1:06:33But it turns out that actually
  1537. 1:06:35they're one of the few models that has
  1538. 1:06:36a clear path to resisting them.
  1539. 1:06:38Linear models are just always going to be linear.
  1540. 1:06:40They don't have much hope of resisting adversarial examples.
  1541. 1:06:44Deep neural nets can be trained to be nonlinear,
  1542. 1:06:46and so it seems like there's a path to a solution for them.
  1543. 1:06:50Even with adversarial training,
  1544. 1:06:52we still find that we aren't able to
  1545. 1:06:55make models where if you optimize the input
  1546. 1:06:57to belong to different classes,
  1547. 1:06:59you get examples in those classes.
  1548. 1:07:01Here I start with a CIFAR-10 truck and I turn it into
  1549. 1:07:04each of the 10 different CIFAR-10 classes.
  1550. 1:07:07Toward the middle of the plot
  1551. 1:07:09you can see that the truck has started
  1552. 1:07:10to look a little bit like a bird.
  1553. 1:07:12But the bird class is the only one
  1554. 1:07:13that we've come anywhere near hitting.
  1555. 1:07:15So even with adversarial training,
  1556. 1:07:17we're still very far from solving this problem.
  1557. 1:07:21When we do adversarial training,
  1558. 1:07:23we rely on having labels for all the examples.
  1559. 1:07:25We have an image that's labeled as a bird.
  1560. 1:07:27We make a perturbation that's designed
  1561. 1:07:28to decrease the probability of the bird class,
  1562. 1:07:30and we train the model
  1563. 1:07:32that the image should still be a bird.
  1564. 1:07:33But what if you don't have labels?
  1565. 1:07:35It turns out that you can actually train without labels.
  1566. 1:07:39You ask the model to predict the label of the first image.
  1567. 1:07:42So if you've trained for a little while
  1568. 1:07:44and your model isn't perfect yet,
  1569. 1:07:45it might say, oh, maybe this is a bird, maybe it's a plane.
  1570. 1:07:47There's some blue sky there,
  1571. 1:07:49I'm not sure which of these two classes it is.
  1572. 1:07:51Then we make an adversarial perturbation
  1573. 1:07:53that's intended to change the guess
  1574. 1:07:55and we just try to make it say, oh this is a truck,
  1575. 1:07:58or something like that.
  1576. 1:07:59It's not whatever you believed it was before.
  1577. 1:08:01You can then train it to say
  1578. 1:08:02that the distribution of our classes
  1579. 1:08:04should still be the same as it was before,
  1580. 1:08:06but this should still be considered
  1581. 1:08:08probably a bird or a plane.
  1582. 1:08:10This technique is called virtual adversarial training,
  1583. 1:08:12and it was invented by Takeru Miyato.
  1584. 1:08:15He was my Intern at Google after he did this work.
  1585. 1:08:18At Google we invited him to come and apply his invention
  1586. 1:08:22to text classification,
  1587. 1:08:25because this ability to learn from unlabeled examples
  1588. 1:08:29makes it possible to do semi-supervised learning
  1589. 1:08:32where you learn from both unlabeled and labeled examples.
  1590. 1:08:35And there's quite a lot of unlabeled text in the world.
  1591. 1:08:38So we were able to bring down the error rate
  1592. 1:08:41on several different text classification tasks
  1593. 1:08:43by using this virtual adversarial training.
  1594. 1:08:47Finally, there's a lot of problems where
  1595. 1:08:49we'd like to use neural nets
  1596. 1:08:52to guide optimization procedures.
  1597. 1:08:54If we want to make a very, very fast car,
  1598. 1:08:57we could imagine a neural net that looks
  1599. 1:08:59at the blueprints for a car
  1600. 1:09:01and predicts how fast it will go.
  1601. 1:09:02If we could then optimize
  1602. 1:09:04with respect to the input of the neural net
  1603. 1:09:06and find the blueprint
  1604. 1:09:07that it predicts would go the fastest,
  1605. 1:09:09we could build an incredibly fast car.
  1606. 1:09:11Unfortunately, what we get right now
  1607. 1:09:13is not a blueprint for a fast car.
  1608. 1:09:14We get an adversarial example that the model
  1609. 1:09:16thinks is going to be very fast.
  1610. 1:09:18If we're able to solve the adversarial example problem,
  1611. 1:09:21we'll be able to solve
  1612. 1:09:23this model-based optimization problem.
  1613. 1:09:25I like to call model-based optimization
  1614. 1:09:27the universal engineering machine.
  1615. 1:09:29If we're able to do model-based optimization,
  1616. 1:09:32we'll be able to write down a function that describes
  1617. 1:09:34a thing that doesn't exist yet but we wish that we had.
  1618. 1:09:37And then gradient descent and neural nets
  1619. 1:09:39will figure out how to build it for us.
  1620. 1:09:41We can use that to design new genes and new molecules
  1621. 1:09:44for medicinal drugs,
  1622. 1:09:45and new circuits
  1623. 1:09:48to make GPUs run faster and things like that.
  1624. 1:09:51So I think overall, solving this problem
  1625. 1:09:53could unlock a lot of potential technological advances.
  1626. 1:09:58In conclusion, attacking machine learning models
  1627. 1:10:00is extremely easy,
  1628. 1:10:01and defending them is extremely difficult.
  1629. 1:10:03If you use adversarial training
  1630. 1:10:06you can get a little bit of a defense,
  1631. 1:10:07but there's still many caveats
  1632. 1:10:09associated with that defense.
  1633. 1:10:11Adversarial training and virtual adversarial training
  1634. 1:10:13also make it possible to regularize your model
  1635. 1:10:16and even learn from unlabeled data
  1636. 1:10:18so you can do better on regular test examples,
  1637. 1:10:21even if you're not concerned about facing an adversary.
  1638. 1:10:23And finally, if we're able to solve all of these problems,
  1639. 1:10:26we'll be able to build a black box model-based optimization
  1640. 1:10:29system that can solve all kinds of engineering problems
  1641. 1:10:32that are holding us back in many different fields.
  1642. 1:10:35I think I have a few minutes left for questions.
  1643. 1:10:39[audience applauds]
  1644. 1:10:47[speaker drowned out]
  1645. 1:10:57Yeah.
  1646. 1:11:15Oh, so,
  1647. 1:11:16there's some determinism
  1648. 1:11:18to the choice of those 50 directions.
  1649. 1:11:22Oh right, yeah.
  1650. 1:11:23So repeating the questions.
  1651. 1:11:24I've said that the same perturbation
  1652. 1:11:26can fool many different models
  1653. 1:11:27or the same perturbation can be applied
  1654. 1:11:29to many different clean examples.
  1655. 1:11:31I've also said that the subspace
  1656. 1:11:33of adversarial perturbations is only about 50 dimensional,
  1657. 1:11:37even if the input dimension is 3,000 dimensional.
  1658. 1:11:40So how is it that these subspaces intersect?
  1659. 1:11:43The reason is that the choice of the subspace directions
  1660. 1:11:47is not completely random.
  1661. 1:11:49It's generally going to be something like
  1662. 1:11:51pointing from one class centroid to another class centroid.
  1663. 1:11:55And if you look at that vector and visualize it as an image,
  1664. 1:12:00it might not be meaningful to a human
  1665. 1:12:03just because humans aren't very good
  1666. 1:12:04at imagining what class centroids look like.
  1667. 1:12:06And we're really bad at imagining
  1668. 1:12:07differences between centroids.
  1669. 1:12:10But there is more or less this systematic effect
  1670. 1:12:12that causes different models to learn
  1671. 1:12:14similar linear functions,
  1672. 1:12:17just because they're trying to solve the same task.
  1673. 1:12:22[speaker drowned out]
  1674. 1:12:27Yeah, so the question is, is it possible to identify
  1675. 1:12:29which layer contributes the most to this issue?
  1676. 1:12:33One thing is that if you,
  1677. 1:12:36the last layer is somewhat important.
  1678. 1:12:39Because, say that you made a feature extractor
  1679. 1:12:42that's completely robust to adversarial perturbations
  1680. 1:12:45and can shrink them to be very, very small,
  1681. 1:12:48and then the last layer is still linear.
  1682. 1:12:51Then it has all the problems that are typically associated
  1683. 1:12:53with linear models.
  1684. 1:12:57And generally you can do adversarial training
  1685. 1:13:00where you perturb all the different layers,
  1686. 1:13:02all the hidden layers as well as the input.
  1687. 1:13:04In this lecture I only described perturbing the input
  1688. 1:13:06because it seems like that's where
  1689. 1:13:07most of the benefit comes from.
  1690. 1:13:09The one thing that you can't do with adversarial training
  1691. 1:13:11is perturb the very last layer before the softmax,
  1692. 1:13:14because that linear layer at the end
  1693. 1:13:15has no way of learning to resist the perturbations.
  1694. 1:13:18Doing adversarial training at that layer
  1695. 1:13:20usually just breaks the whole process.
  1696. 1:13:23But other than that, it seems very problem dependent.
  1697. 1:13:27There's a paper by Sara Sabour and her collaborators
  1698. 1:13:30called Adversarial Manipulation of Deep Representations,
  1699. 1:13:34where they design adversarial examples
  1700. 1:13:36that are intended to fool different layers of the net.
  1701. 1:13:41They report some things about, like,
  1702. 1:13:43how large of a perturbation is needed at the input
  1703. 1:13:45to get different sizes of perturbation
  1704. 1:13:47at different hidden layers.
  1705. 1:13:49I suspect that if you trained the model
  1706. 1:13:50to resist perturbations at one layer,
  1707. 1:13:52then another layer would become more vulnerable
  1708. 1:13:54and it would be like a moving target.
  1709. 1:14:00[speaker drowned out]
  1710. 1:14:09Yes, so the question is,
  1711. 1:14:10how many adversarial examples are needed
  1712. 1:14:12to improve the misclassification rate?
  1713. 1:14:15Some of our plots we include learning curves.
  1714. 1:14:20Or some of our papers we include learning curves,
  1715. 1:14:22so you can actually see,
  1716. 1:14:25like in this one here.
  1717. 1:14:26Every time we do an epoch we've generated the same
  1718. 1:14:29number of adversarial examples
  1719. 1:14:31as there are training examples.
  1720. 1:14:33So every epoch here is 50,000 adversarial examples.
  1721. 1:14:37You can see that adversarial training is a very
  1722. 1:14:41data hungry process.
  1723. 1:14:43You need to make new adversarial examples
  1724. 1:14:45every time you update the weights.
  1725. 1:14:47And they're constantly changing in reaction to
  1726. 1:14:51whatever the model has learned most recently.
  1727. 1:14:55[speaker drowned out]
  1728. 1:15:07Oh, the model-based optimization, yeah.
  1729. 1:15:11Yeah, so the question is just to
  1730. 1:15:13elaborate further on this problem.
  1731. 1:15:16So most of the time that we have a machine learning model,
  1732. 1:15:20it's something like a classifier or a regression model
  1733. 1:15:23where we give it an input from the test set
  1734. 1:15:26and it gives us an output.
  1735. 1:15:29And usually that input is randomly occurring
  1736. 1:15:31and comes from the same distribution as the training set.
  1737. 1:15:34We usually just run the model, get its prediction,
  1738. 1:15:37and then we're done with it.
  1739. 1:15:39Sometimes we have feedback loops,
  1740. 1:15:42like for recommender systems.
  1741. 1:15:44If you work at Netflix and you recommend
  1742. 1:15:47a movie to a viewer, then they're more likely
  1743. 1:15:50to watch that movie and then rate it,
  1744. 1:15:52and then there's going to be more ratings of it
  1745. 1:15:54in your training set
  1746. 1:15:55so you'll recommend it to more people in the future.
  1747. 1:15:57So there's this feedback loop
  1748. 1:15:58from the output of your model to the input.
  1749. 1:16:00Most of the time when we build machine vision systems,
  1750. 1:16:04there's no feedback loop from their output to their input.
  1751. 1:16:08If we imagine a setting
  1752. 1:16:09where we start using an optimization algorithm
  1753. 1:16:11to find inputs that maximize some property of the output,
  1754. 1:16:17like if we have a model that looks
  1755. 1:16:18at the blueprints of a car
  1756. 1:16:20and outputs the expected speed of the car,
  1757. 1:16:24then we could use gradient ascent
  1758. 1:16:27to look for the blueprints that correspond
  1759. 1:16:29to the fastest possible car.
  1760. 1:16:31Or for example if we're designing a medicine,
  1761. 1:16:33we could look for the molecular structure
  1762. 1:16:36that we think is most likely to cure some form of cancer,
  1763. 1:16:40or the least likely to cause
  1764. 1:16:42some kind of liver toxicity effect.
  1765. 1:16:45The problem is that once we start using optimization
  1766. 1:16:49to look for these inputs
  1767. 1:16:50that maximize the output of the model,
  1768. 1:16:53the input is no longer an independent sample
  1769. 1:16:56from the same distribution
  1770. 1:16:58as we used at the training set time.
  1771. 1:17:00The model is now guiding the process
  1772. 1:17:04that generates the data.
  1773. 1:17:06So we end up finding essentially adversarial examples.
  1774. 1:17:11Instead of the model telling us
  1775. 1:17:13how we can improve the input,
  1776. 1:17:15what we usually find in practice
  1777. 1:17:16is that we've got an input that fools the model
  1778. 1:17:19into thinking that the input corresponds to something great.
  1779. 1:17:23So we'd find molecules that are very toxic
  1780. 1:17:26but the model thinks they're very non-toxic.
  1781. 1:17:28Or we'd find cars that are very slow
  1782. 1:17:30but the model thinks are very fast.
  1783. 1:17:35[speaker drowned out]
  1784. 1:17:54Yeah, so the question is,
  1785. 1:17:56here the frog class is boosted by going
  1786. 1:17:58in either the positive or negative adversarial direction.
  1787. 1:18:01And in some of the other slides, like these maps,
  1788. 1:18:06you don't get that effect where subtracting epsilon off
  1789. 1:18:09eventually boosts the adversarial class.
  1790. 1:18:12Part of what's going on is
  1791. 1:18:13I think I'm using larger epsilon here.
  1792. 1:18:16And so you might eventually see that effect
  1793. 1:18:18if I'd made these maps wider.
  1794. 1:18:20I made the maps narrower because
  1795. 1:18:21it's like quadratic time to build a 2D map
  1796. 1:18:25and it's linear time to build a 1D cross section.
  1797. 1:18:29So I just didn't afford the GPU time
  1798. 1:18:33to make the maps quite as wide.
  1799. 1:18:35I also think that this might just be
  1800. 1:18:37a weird effect that happened randomly on this one example.
  1801. 1:18:40It's not something that I remember being used to seeing
  1802. 1:18:42a lot of the time.
  1803. 1:18:43Most things that I observe
  1804. 1:18:45don't happen perfectly consistently.
  1805. 1:18:47But if they happen, like, 80% of the time
  1806. 1:18:50then I'll put them in my slide.
  1807. 1:18:52A lot of what we're doing is trying trying to figure out
  1808. 1:18:54more or less what's going on,
  1809. 1:18:56and so if we find that something happens 80% of the time,
  1810. 1:18:58then I consider it to be the dominant phenomenon
  1811. 1:19:02that we're trying to explain.
  1812. 1:19:03And after we've got a better explanation for that
  1813. 1:19:06then I might start to try to explain
  1814. 1:19:07some of the weirder things that happen,
  1815. 1:19:09like the frog happening with negative epsilon.
  1816. 1:19:15[speaker drowned out]
  1817. 1:19:22I didn't fully understand the question.
  1818. 1:19:24It's about the dimensionality of the adversarial?
  1819. 1:19:34Oh, okay.
  1820. 1:19:35So the question is, how is the dimension
  1821. 1:19:37of the adversarial subspace related
  1822. 1:19:39to the dimension of the input?
  1823. 1:19:40And my answer is somewhat embarrassing,
  1824. 1:19:44which is that we've only run this method on two datasets,
  1825. 1:19:47so we actually don't have a good idea yet.
  1826. 1:19:49But I think it's something interesting to study.
  1827. 1:19:53If I remember correctly, my coauthors open sourced our code.
  1828. 1:19:57So you could probably run it on ImageNet
  1829. 1:19:59without too much trouble.
  1830. 1:20:02My contribution to that paper was in
  1831. 1:20:04the week that I was unemployed
  1832. 1:20:06between working at OpenAI and working at Google,
  1833. 1:20:09so I had access to no GPUS
  1834. 1:20:11and I ran that experiment on my laptop on CPU,
  1835. 1:20:14so it's only really small datasets. [chuckles]
  1836. 1:20:19[speaker drowned out]
  1837. 1:20:40Oh, so the question is, do we end up perturbing
  1838. 1:20:44clean examples to low confidence adversarial examples?
  1839. 1:20:47Yeah, in practice we usually find that
  1840. 1:20:50we can get very high confidence on the output examples.
  1841. 1:20:53One thing in high dimensions that's a little bit unintuitive
  1842. 1:20:57is that just getting the sign right
  1843. 1:21:00on very many of the input pixels
  1844. 1:21:03is enough to get a really strong response.
  1845. 1:21:06So the angle between the weight vector
  1846. 1:21:09matters a lot more than the exact coordinates
  1847. 1:21:13in high dimensional systems.
  1848. 1:21:18Does that make enough sense?
  1849. 1:21:20Yeah, okay.
  1850. 1:21:21- [Man] So we're actually going to [mumbles].
  1851. 1:21:23So if you guys need to leave, that's fine.
  1852. 1:21:26But let's thank our speaker one more time
  1853. 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.