Andrej Karpathy: Software 2.0: Data Is the New Code

On Software 2.0: Data Is the New Code

Full Stack Deep Learning talk, 2018 · February 2018
Video thumbnail: Andrej Karpathy on Software 2.0: Data Is the New Code
55 mintalk5K views across 1 upload11,264-word transcriptWatch on YouTube ↗

What Karpathy talks about

Andrej Karpathy gave this Full Stack Deep Learning talk in 2018 on Tesla’s approach to autonomy, arguing that in modern machine learning systems data collection, labeling, and curation function as a new kind of code.

Also known as: AI at Tesla; Full Stack Deep Learning talk; Software 2.0.

Karpathy explains why building AI at Tesla changed his view of programming: the hardest part was not model architecture, but collecting, labeling, and curating data. He argues that in modern machine learning systems, the dataset becomes a form of code, and the human labelers are effectively the programmers.

He uses Autopilot and the auto-wiper system to show how real-world deployment creates endless edge cases, feedback loops, and data-engineering work. That leads him to propose a “data engine” and a future “2.0 IDE” for inspecting datasets, finding bad labels, and iterating models more systematically.

Karpathy gives the talk and answers audience questions at the end.

In his words

“Code—that code is not written in C++. It's written in weights of a neural network.”
at 0:45
“The labelers are kind of the programmers”
at 4:21
“What does the GitHub 2.0 code look like?”
at 22:38

Key points

  • Tesla forced a shift in emphasis from algorithms to data quality, labeling, and infrastructure.
  • “Software 2.0” means neural networks write parts of the program through optimization, not human hand-coding.
  • In practice, labelers and data curation teams are the real programmers because they shape model behavior.
  • Real autonomy work depends on building a data engine: find failures, collect examples, relabel, retrain, redeploy.
  • Industrial ML data is messy: rare classes, changing label definitions, ambiguous edge cases, and non-uniform distributions.
  • A good ML workflow needs tooling like a 2.0 IDE for dataset inspection, label comparison, error detection, and active sampling.
  • Karpathy thinks hardware, especially specialized accelerators, will keep evolving to better fit neural-network workloads.

Full transcript: Andrej Karpathy, Software 2.0: Data Is the New Code (2018)

Um, so what I find interesting is usually when it comes to applying deep learning and so on, there's a lot about, you know, the latest research, the latest networks. There's a lot of focus on, uh, you know, the algorithms and models part of it. And I guess it's always kind of shocking to me because kind of going to Tesla a year ago and trying to basically get machine-applied machine learning to really work well in the real world looks a little different than I kind of anticipated. Data. So what I'm used to and what I'm familiar with is reading a lot of papers, knowing a lot about how these algorithms work and how to train them and potentially how to deploy them. Some of that you've been looking at today. Um, what I found kind of shocking was that a huge amount of my time ended up just empirically being

spent on the data set and just massaging all the data sets. So I wanted to talk a little bit about that and I, I hope you find it useful, interesting and, um, yeah, be available. Yes, I'm told they will be available. Yes. Um, yes. So, as I see it, I think there's actually kind of a little bit of a seismic shift, I suppose, in how we actually program computers today. And so, I have a whole blog post on it, the whole rank. Um, in what I refer to as a software 1.0 stack, which is code written by humans, and a software 2.0 stack, which is code—that code is not written in C++. It's written in weights of a neural network. And that code is not written by humans. It's written by the optimization, um, according to some kind of objective. And so kind of what

this looks like is that if you imagine the program space, um, software 1.0 code basically constitutes, um, basically corresponds to actually identifying a single point in that space that's accomplishing your task. Whereas a software 2.0, you're kind of identifying an architecture, right? So you're kind of identifying a set of programs that you're hoping contains a solution to your problem and then usually has some kind of an evaluation criterion, uh, that tells you how well you're doing. And then basically you're outlining a space of programs, which is identifying the architecture, and then optimization actually, like finds the program in that space that actually seems to work well according to your criterion. So normally when you're coding, you would, uh, you would write something, you would evaluate it, and then you would iterate on that with yourself. Uh, here that's kind of happening automatically. So I think it's

really interesting. Um, I kind of had this, uh, tweet from a very long time ago. I guess a year ago now feels like a long time ago. It said, "Gradient descent can write, uh, code better than you." I'm sorry. And I think many people didn't quite understand what that refers to. And so there were some replies that looked pretty confusing. (music) It was like the most highly replied. Um, so I could see that it's, it's not this, not quite sinking into people that grad is actually writing code and that it is code from that perspective. To me it was very clear just because, for example, looking at Autopilot, uh, we have a number of inputs, and they feed into the stack, and then at the end of the stack, really, we're operating two numbers where two scalars come out: the steering and the

acceleration. And, uh, there's this mel of code, right? Because at some point in there, we have a convolutional neural network, and that looks at the image and gives you some outputs, and those intermediate outputs feed into the rest of the stack. And, um, so it's kind of very obvious from that perspective that some of the code is human, and some of the code is just kind of dropped in from the optimization. And over the last year that I've been at Tesla, it's kind of starting to take over just because I mentioned that's kind of like my hammer. And I think if you do this well, things end up working better. And, um, so I certainly see us trading off 1.0 code for 2.0 code. And it's kind of interesting. Um, as a concrete example of that that I like to show is, um, we had a part of the system that was trying to look at whether or not a car is parked. And you might actually, because that's useful from a perspective of control, you might control differently around

parked vehicles than not parked vehicles. And you can imagine saying things like, okay, well, a car is probably parked if it hasn't moved in a while, and, um, there's maybe a pattern to them or something like that. You can imagine some of the rules around it when I think the correct thing to do is to pretty much just say, um, actually you could, uh, cars part if the network says so, right? So because a network has significantly more context and can write the code much better than a human could and has, uh, information from the image that's much more global than what you have in your representation. So this isn't just, like, the right way to go. Um, and so what we're seeing, I think, is this kind of like a shift from how historically computer science has looked like and what started to look like now, in that what has been cool for a while and when you look at computer science and you take your courses in undergrad

and so on, everything looks like this. So you write cool algorithms, you look at their running times, etc., and you're trying to be clever and you feel good about yourself. And I think there's a transition to, uh, something that looks like this. There's this workforce actually the way program actually splits into two categories. There's a portion of people who basically look at the raw data and they annotate it with a number of layers. So we have these kind of labelers basically doing a lot of the work in annotating the app and then, um, there's a lot of infrastructure that's trying to help out the labelers, and so since the way we do this is we train networks on data sets, and the way we program is by accumulating these data sets, and, um, effectively what's happening is that it's flipping around because the labelers are kind of the programmers because by curating data sets they're

Really, um, informing the final functioning of the system. So they are programming, and we're kind of just like helping them out. And we see this at Tesla as well. We have a data labeling team and so on, and, uh, they're the real programmers because they look at our data and how it's labeled, and we just maintain a bunch of stuff with them and hope that they can do it well. Um, so what are some of the things that, um, that we might want to label just to make this more concrete? So here's an image from the fleet. This is kind of like what we have to work with, and, uh, so you can see that we're some kind of a road. We have to understand this so that we can drive on it. So obviously, we want to know potentially, for example, about the vehicles, about the lane lines, about what's drivable or not drivable, like where we can even go. Uh, we want to know about all the signs and traffic signs and, of course, like traffic lights and things like that. So we need to annotate

a lot of this stuff on, on all these, and, um, so what I find kind of interesting is starting at scratch in any kind of industrial application you'll actually, um, it will look very different because normally in academia you are given ImageNet or you are given some other data set of interest. But in almost all practical applications, you actually have to create your own data set, and, um, so that's kind of like, I suppose, a little bit of a fun story because, uh, for me this very quickly kind of ran against the wall of actually just even trying to create those data sets. So, uh, some of the things that you might think are extremely easy, um, end up being quite hard. So, for example, uh, obviously you need to know where the lane lines are, uh, so that you can drive. So me, I think week three or something like that, I was like, okay, well, we need to know where the lane line markings are. So we're going

to redesign the documentation on how that's done. And I was like, okay, here's a single image. So how hard can this be? Just one line, two lines. And I thought this was pretty straightforward. And then you go out into the world, especially with us we have a global fleet and there are a lot of crazy places on Earth. (music) So, um, so you know, this came back and the labelers got confused and like, what are we supposed to do? Do we follow this exactly, try to interpolate? What do you want us to do? And then I have to think first for a very long time, and then I have to change the labeling documentation, and then we have to make sure that all the labelers are actually aware of how to handle this case and that they're all consistent with each other. And so, um, yeah, sometimes roads do funny things. So here, little road just kind of like departs for a bit. It's not

obvious if you should follow that thing or if you should interpolate through it. Whatever you do decide, uh, you have to be consistent and you have to make sure that everyone knows, and maybe what happens later is you actually change your mind because you think, maybe we should follow it, and then it creates all kinds of problems for the controller, and then controllers like, hey, actually, we don't want this. Can you actually prove true? And I'm like, okay, we can do that. But suddenly I have 10,000 images that are mislabeled. They're incorrectly labeled in my data set. And now you end up with a mel of deprecated instructions in your data set. So you can see how this quickly becomes pretty complicated. Um, yeah, there's a lot of crazy stuff out there that you have to handle specifically. So this grows to like 20, 30 pages of documentation very quickly. On the Autobahn, uh, there's always construction. The rule is that the orange lane lines take precedence over

white lane lines. So, uh, you have to listen to the orange ones instead of the white ones. And this is of course troubling because now you have a lot of images where the network is obviously confused, and now you're not—it's not obvious like how you handle this. Do you tell the labelers to actually just label the yellow lines and ignore the other ones? Or do you label both and then you try to like switch between them at test time? You have to really think through some of these philosophical repercussions. Um, in Honolulu, the layout markings look really funny. So, um, because they're like washed out. And so this is again an example where, um, you have your data set and now you're fighting this battle all the time where you have these edge cases, and especially if you're in a safety critical kind of application you really want to make sure that you have these in your data set, right? Because the way I fix this, suppose a network is mispredicting, how do you

fix that in a new machine learning stack is you need lots of examples of it. So now I need 10, 2,000 thousand examples of it, and I need to label through it, uh, because there's no other way to explicitly hand code that stuff. Um, also for labeling cars, there's a huge amount of stuff that again, like you can put wheels on and put on a road. So, I thought this could be pretty straightforward. We just put bounding boxes around things. And then there's a lot of crazy stuff out there. So, um, it's not obvious if you want to label this as a single car or as four cars or as two cars. Um, and whatever you decide, you have to be consistent with it. Uh, sometimes you find things like this. Um, also very tricky because it's not obvious the whole thing is a car. It definitely moves together. So it should be a simple but what is the network

Supposed to make of that when you only have like a few examples in your training set. Uh, so clearly that's not going to work well if in your data set you have one of this or five of this. You maybe need 100 or thousand or maybe you need to handle that separately as a separate training task. Like, it's only really not obvious how you extract this. Um, yeah, uh, traffic lights are, I also thought, were going to be pretty straightforward because we just, you know, there we go: polygon, polygon, red, green. But these can get pretty complex, especially again we have global product, so you have to actually worry a lot about, um, you know, the labeling documentation and again if you make any changes later you're actually a lot of your data set is mislabeled and this keeps, keep this keeps happening. It's

pretty tricky. Um, for speed limits also, this labeling speed limits is also not going to happen because those AI complete very quickly. Uh, so you might—I'm hoping the one on the very left is a joke, but I'm not 100% sure. Um, yeah, so it's all, it's almost like, okay, is this a regression task? Is this a classification task? And then all the other attributes and how do you even, if you create a new attribute for, for example, for a half or something like that, that's obviously not going to work if you only have 10 examples of it or 100 examples of it. So now the question is, okay, I need 10,000 of that. How do I get it? And if you have a fleet, maybe it's trackable. If you don't have a fleet, good luck. Uh, not obvious. Um,

Some of the other challenges with data sets and what I don't see in academia really being tackled, but is probably pretty common in the industry, is, uh, there are huge legal imbalances in what you want to actually do. So for example, you want to detect, uh, when blinkers are on or left or right because obviously you want to predict cuts and handles gracefully. But the problem is that if you just label, um, uh, if you just get your images at random from the fleet, then labeling left and right blinker on is going to be extremely rare for them to be on. Right? Most of the time they're off. So you will end up with a million examples of them being off and it costs you a huge amount of time to annotate and you'll have 100 examples sprinkled in. So obviously you need to do something clever about sourcing those rare examples and a lot of the infrastructure associated with getting examples that, uh, that you have

this link on. So as I mentioned briefly in my previous, um, uh, talk, we can do things like, you know, um, "Hey fleet, can you please send us images when a car's transition from left to right lane or to central link?" and that helps a ton, right? Because suddenly we can have hundreds of thousands of images and instead of having a 1% fraction has a blinker on, we go up to 50% fraction has a blinker on. So that's incredibly helpful. Another example of that is the orange traffic light. We have very few orange traffic lights. So our mapper currently actually quite struggles with that. It has the red and the green down, but orange it struggles with and, um, how do you fix it? Of course you need more examples of it and how do you get those? So we do, we can do like, in principle, pretty clever things around, okay, suppose you're at a

um, you're stopped near a traffic light region and the traffic was stopped and then start suddenly started to move rewind time 3 seconds or something like that and take a snapshot from then. So we can, we do have infrastructure for stuff like this, and it's extremely important and this is not just for us but for any other machine learning problem you have to start thinking about how you actually design these and how you create infrastructure for yourself to actually source examples in their cases. Uh, the other problems are not just label imbalances but also data imbalances. So most of our data actually looks like this: traffic on the highway, straight. This is 90% of our data if you just sample uniformly at random. But then you have to be careful because you go into a wet situation and suddenly, um, you know, the network might struggle if you don't have a lot of examples of wet

environments or if you go to San Francisco, good luck. Um, yeah, so that's why I think it's kind of really interesting that we don't in academia or this is not a well-studied kind of problem setting and I think it's extremely common and it's shockingly not covered. So, you know, this is standard C10, what's, uh, what does CR10 look like as a small, as a small example? Well, it's a clean label data set, right? So that's first of all, that's not guaranteed in any kind of application. So okay, let's assume it's cleanly labeled here. Um, you have an even class distribution, so you have exact number of classes in, in each type, exact number of images in each

class. Um, you have a single classification task so you're just predicting these 10 and it's fully supervised so you don't have any withheld unlabeled examples or something like that. This is all that you have and they're cleanly labeled and it's a uniform distribution, so that's kind of crazy. And so I think, um, I was trying to kind of like come up with a realistic cart and I think someone could maybe build this. I don't have the time but I think it would be kind of interesting to try to, based on what I've noticed at least at Tesla and I think I suspect is common to other machine learning settings. So here's some suggestions for maybe what you want to do. 5% of your labels are randomly just incorrect. Um, one of the things that we struggle with a lot so suppose you take beer, airplane, and chocolate, some of the classes and you throw away most of your examples. So you only have very few but actually these could be safety critical.

Examples, for example. So suddenly you need—you require that the test loss is actually pretty good on those three as a strong constraint, even though you have very few examples of them. Um, the other thing you could do, for example, is, uh, one of the things we're dealing with is we don't just predict a single thing about that image. We actually have, I think, almost like 20 tasks that you want to know about any single image. I only showed you some examples like traffic speed limits and lines and driver space and, you know, lots of things you might want to know about the image. They blow up pretty quickly. Cutting predictions and stuff like that. And so suddenly, you're dealing with a super multitask setting, and actually training those is not a very well-explored, uh, on how you do that very well. So here, I would propose that we add some more tasks. And the other really large aspect that is different is that, uh, because of the fleet, and I suspect this is true in

other applications as well, you have an unlabeled data set that is pretty massive, and you can choose to annotate things. You have a certain budget, and you can annotate arbitrary data. And so, uh, you have some kind of withheld set of images that secretly contain labels, and you can query those labels, but you only have a finite budget like, say, 1,000 times because you don't want to pay infinite money. Um, you, times, you can ask for one of those images to be labeled. So that's kind of like a much more realistic kind of setup. I think it could be interesting, uh, for stuff. Let me give you a concrete example of the development cycle in the programming stack 2.0. The—the one I—I’ll use is the auto wiper. Uh, so the auto wiper is, uh, something that, um, so basically normally would have a rain sensor in a car that senses if there's like a lot of

rain on the windshield, and then it turns on the auto wiper. Uh, but in our case, this sensor actually costs money. So this idea was that we don't need the sensor and vision can do it. So we have a camera behind the windshield and it's, uh, looking out, and you can basically—it looks something like this; this is not an exact image from our data, but basically, you can kind of see raindrops on the windshield sometimes. And I thought this was going to be pretty straightforward because they're obviously noticeable, and this should be pretty easy to overcome that. So I, I thought, okay, this is going to be pretty straightforward. We're just gonna collect our labels. We're going to train some model, and we're going to try to deploy it. And that turned into a little bit of disaster because there's a huge amount of edge cases. Uh, so frost, um, dust, um, tunnels turned out to be, um, surprisingly really difficult. And when a sun was

shining onto the, um, sensor, it was creating all kinds of, um, issues with the original network. And so basically what you're observing is you collect your first set of examples, you train your network, and it has a bunch of failure modes. And now, how do you fix those failure modes? You need examples of those failure modes. You need to correctly annotate them, and then you need to incorporate them into your training set. And so, um, this is what I refer to as a data engine. And I think basically every single machine learning—applied machine learning, um, uh, process must have some kind of a data engine associated with it. And there's no tooling for this. It's not developed. And that many people don't talk about it too much. But there's a development life cycle for machine learning applications, right? So, uh, I have some kind of a network that's deployed in fate. There's certain problems, and then the way I fix those problems is I need to boost

examples of those problems, and then I need to correctly label them, and I need to retrain my network and redeploy it, and then that will create a different, uh, error distribution, and I need to, like, iterate this until I squash all the errors. Um, and so this is something that we have not just for the ROI but for all the tasks, and we're trying to make it as automated as possible because obviously this is how you fix all the errors in a machine learning stack because there's no one who's programmatically fixing these errors. Uh, so for the auto wiper, we did this and it turned out okay. I'll just show you some examples of—it's kind of funny. Um, definitely. Is this a—this is not video? Okay. Okay. So, I don't have the video, but it's a YouTube video called "Will It Wipe" that I encourage you to look at because we shipped this a while ago and it half works. And, uh, when you pour water onto

the windshield, the auto wipers will wake up and they see the—the water, and they will wipe the windshield. Um, so that wipes and then corn flakes, it turns out, white thinks that this is rain and good enough. Um, it's not part of our data engine that we did not consider cornflake examples. Um, and then it turns out that ketchup does not wipe. So depending on how you want your stack to handle ketchup on the windshield, you might want to label incorporate. Okay. So basically, um, I guess what I'm getting at is what's interesting is I think the programming paradigm is changing, uh, and how we inter—how we build software is changing, and, um, normally in the 1.0 code code stack

we've been working with this for decades, and so we actually have built out a lot of sophisticated tooling for running programs in the 1.0 stack. So in particular, we have all these IDEs, um, for helping us write code. So you have syntax highlighting and go to definition and, and, uh, debugger and profiler and etc. These IDEs are sophisticated programs that help you write 1.0 code. So I—what is a cool good IDE for writing 2.0 code? And I think it's completely not built out, and it's not obvious what it's going to look like, but I guess I can speak to a few examples of what I see at least at Tesla. And I suspect that this is some of the features that a 2.0 IDE could offer. There might be more, but some of the things we're finding useful, for example, is, um, showing obviously when your data set will be compiled by the optimization into the network. So your

Dataset is really code, um, or like a, yeah, predecessor of the code, I suppose. And so you really want to know what's in the dataset, and you want to slice and dice it different ways and get statistics over different labels and types of things in your data. This is extremely important. Someone needs to be able to look at it, visualize it, understand it, and that really tells you how things are going to work at test time. Um, we do a lot of stuff around creating and editing annotation layers. So it's pretty straightforward to actually change the dataset. Um, usually you have teams of labelers that are working on your data. You need, and they will disagree, and different people will disagree with each other. So you actually want to, um, a lot of the times what we do is like 10% of the data, for example, is assigned to two people instead of one person. And then you want to have a distance function of your labels and you want to flag when two

people incorrectly labeled or differently labeled some single image, and you need to raise it to them so that they actually improve over time as well because a lot of this labeling is, as I showed you above, is non-trivial and even for me sometimes it's tricky to even say how an example should be labeled. So really, really tricky and needs a lot of, um, coaching. Um, we have a lot of tooling for detecting automatically that something is mislabeled. I think I have an image for that in a few slides. Uh, that's pretty useful because you can actually compute that based on loss. So your network has a suspicion that something is incorrectly labeled when its prediction disagrees with the label by a lot. Um, we find it very useful to overlay predictions on top of this, and, um, we have some infrastructure for okay, you have an unlabeled collection of images

some of them you might want to label, and there are a number of approaches that you could actually take to, uh, suggesting what should be labeled. So, for example, if your network is at a high entropy over some image, then it's uncertain and then you may want to label it, but that will not catch some cases. For example, if your network is confidently wrong about an image, then that will not be caught. Um, so these are some examples of, of, uh, what the infrastructure we are building out kind of, um, addresses. Uh, but really what it comes down to is this actually ends up being a pretty complex toolset that actually, like, starts to mirror some kind of Photoshop-like application because really there's this, uh, workforce of labelers who are detectives over your dataset, and you want to empower them to fix your data. And so it's kind of interesting what

this looks like. And I have a slide here showing an example of how we bubble up images that we find are suspicious. And we find this really helpful because our data, a lot of it is incorrectly, um, uh, labeled because the person was inattentive, but a lot of it is incorrectly annotated just because we have deprecated labels and we've changed the instructions or it's, uh, just mistakes and stuff like that. So, um, the network will find different things suspicious in different amounts, and that's pretty helpful. So, um, and, um, yeah, as I mentioned, you can pay money to annotate data and choosing it is, is an extremely interesting, uh, the other thing that I find kind of interesting is that, um, you know, like treating this as programming is really interesting because it suggests immediately analogies for what you might

want in the 2.0 stack and it kind of bubbles up interesting things to build. So, for example, there's a GitHub for 1.0 code. It's a large repository of code, and, uh, there's a whole website for it and it's a pretty valuable company. So I guess my question is, uh, what does the GitHub 2.0 code look like? Because no one has built it yet, but I think this new programming paradigm probably should exist. And, um, really the software 2.0 code is a result of two pieces. Instead of just the code, you actually have the datasets, and then you also have the neural network training code that will take those datasets and create you a program. And so, and that's usually written in 1.0 code. So most of the code is kind of roughly written in examples and then some of it is also the neurologic training code itself. And so it's two entities instead of one kind of

it's kind of interesting. Um yeah, but, uh, yeah, I think that's a, I think I'm like very early. Maybe I was—maybe I was this one hour talk. Okay, I can take quite a few Q&A and then the next talk. Yeah, that's what I ELSE. How do you deal with, um, evolving functionality and the need for that functionality or supporting that functionality driving back up increasing

the labels for your data? For example, you're looking at a scene. Maybe today you're just interested in the lanes, but future functionality may require you to classify the scene even further and say it's a countryside, there's clouds in the sky, etc., right? So, how do you keep that whole revision going to support your function? Yeah, exactly. So I think the way we're thinking about it is you are basically creating annotation layers over your data and you can create a new layer and there's actually not too many different types of tasks like I think tasks basically fall into for us, for example, into three buckets. There's a detection-like task, segmentation-like task, and a classification-like task and we technically have like 20 to 30 tasks but they're all an instance of these three.

So you can create annotation layers, and you can, um, characterize them as a section-like thing or whatever-like thing. And so there's some kind of almost like a dictionary or task that's kind of emerging here. And what's interesting is that once you have these layers, you can automatically generate the code, the architecture that could actually fit that data. Uh, so how do you go from, okay, these—as I mentioned, we have this workforce of, um, 2.0 programmers, sort of like—they should be able to create a new annotation layer, and they will annotate some things, and then the UI should actually auto-suggest things that they might want to annotate. Like, okay, you label this as this, and what about this? I'm pretty uncertain. And then they label that. And, you know, how do you actually are in a loop with these programmers and help them? And then how do you automatically kind of, um, get your—how do you automatically recompile the...

Network that actually fits that data. Uh, so that life cycle could actually be to a large extent automated. Uh, so you literally have a completely automated pipeline from like annotation layers and a set of them and their types and the data, and then all the way to the network that actually implements that. Uh, so there's a definite possibility to actually automate large pieces of that. Have you, um, considered, uh, using your models as pre-labelers to see how much gain you get in the efficiency of the label? Oh, yeah. Okay. So it's a really interesting point. So, uh, basically automated annotation, basically, because, um, suppose you actually have a pretty good network. You can actually pre-populate your annotations and then people can like adjust them. I've been

Like, slightly, um, afraid to do that because here's what's interesting about that. Suppose your network is, um, is wrong a little bit. Suppose it has a bias of like two pixels because the detector is not very well trained — offsets all the boxes by two. I'm afraid that basically people will be looking at it and they're too lazy to fix it and, uh, and suddenly you have so much bias and like your network drifts because it's two pixels off now. And then many people will say, "Oh, it's pretty good, pretty good, pretty good." And then that gets into the training set and now you have a non-stationary distribution and your network is drifting. You could evaluate that though by doing treatment groups, right? See how much bias you might get from doing that. So yeah, just you can't. Yeah. Yeah. So yeah, I'm thinking that like humans, um, they have — what's nice about humans is the variance is large.

But their bias is zero, which is desirable, but your neural network, the variance will be very small. But I'm afraid that the bias is not zero, and that would be bad because your network just becomes incorrect in a very consistent way. And so I've been pretty hesitant to actually incorporate that into the workflow, but it's so appealing because in many cases, it's going to speed up the annotation by a lot. Um, so I think this is a pretty deep, interesting question. I'm hesitant to do it so far. Um, but I can see the appeal. It's a really interesting question. Uh, yeah, considering you have a global field, h, how much training is done on on data set?

Globally versus locally? And do we train like here on German, or how do you switch? So, like, do you have separate models for different engines, for example? Just one model? So, it's not—yeah. So just to generalize the question, make it not too much about Tesla—I’m hesitant to speak to it in detail, of course, Tesla—but like, how do you carve out... um, how do you, basically? The question, slightly more general version of it, is if you have slightly different looking examples, is it beneficial to have different networks for it, or do you actually want one network to juggle it all? And, um, it’s actually... uh, so what’s interesting is that this network actually, since there are all these layers and the first layers are just learning to see basic edges and so on. And so you’d actually—

Hope that you get a lot more statistical power out of having 2x the data for those detectors over there on the lower level, and then some of it changes up there. But actually, both German networks and US networks have to have edge detectors, and so you actually don't want to really split your data too much because then those edge detectors can't be trained as well as they could jointly. So I'm usually a bigger fan of keeping some of the structure, and then the question is exactly where you branch off. That would probably be a question, like, a problem-specific thing, but I suspect that you actually want to keep some of the lower layers equal because all those intermediate feature detectors will be similar. And some of the rules of driving will be different, but that's like pretty high up top. That makes sense. Yeah, that's interesting. Would the branching off be, you know...

Based on where you are, or would that be part of the input? Uh, so I think, um, so it's an interesting question. So, um, for example, do you have separate heads, I suppose, of a network for Germany and for the US? Or do you somehow plug in an identity into the network, and they're actually kind of like equivalent to some extent? Like, suppose you only have two regions, like Germany and the US. Then plugging in a bit of "are you in the US or not" is, uh, if that bit kind of interacts in the network multiplicatively with your weights, then you're basically switching between two architectures. And so really what it comes down to is when you have a small discrete set of categories, you actually might want to switch between them, but if you have like a large set of, like, say...

You have the US, and like, you have so many different countries, you might actually plug in a country code because you don't want to have like 10,000 heads or something like that. Um, but then how you actually get that to interact with the features, like, is it multiplicative or some kind of a, or do you just concatenate and have more NAP stuff above it? And it's the exact fusion is actually interesting. I mean, it could be regional too within your scope. Yeah, like you can go nuts with this because then maybe you want to network for snow versus sky or maybe time of day. So like you can go arbitrarily granular and at some point it's not obvious that it's a good idea. Um, so the labeling site obviously is labor intensive and humans should be—can you elaborate on the downward arrow of the problem?

The downward arrow of—yeah, so um, I'm thinking that in every application this will look a little bit different. For us, for example, whenever a person intervenes for an autopilot, that is almost always a strong signal that something went wrong. Other ways that we can tell is, uh, high network uncertainty is an example. Uh, normally also when networks are uncertain, the way that usually manifests is jitter over time. Uh, so that is also a signal for it. Uh, there's a few other ones that are kind of interesting, but um, basically what it comes down to is we have a number of signals that tell us when something is not quite working, and temporal jitter is an example and uncertainty is an example. Um, and then more task-specific things would be an example. And so that arrow there—

Unfortunately, is not, um, it kind of depends on per task, and each different task will have its own way of noticing their going—kind of elaborating on it. So, is there cases where, uh, you find an issue with like software, say, like "come be" a viable solution maybe temporarily while you're collecting more data on the problem? Or like, basically if you're on autopilot, for example, and then you know that, like, this is like a flagged area, like an issue, then you would, I don't know, maybe like require the driver to like take control in that instance because it's safer, like, while you're collecting more information for that particular—Oh, I—Okay. So, what this brings up is—

Actually a really interesting point in in that for all of these things, uh, there's actually like two things which is like: can you, can you do the right thing? And then the other thing is can you recognize that you can't do the right thing? And the latter is actually like an easier problem. So like giving up is actually a really interesting, uh, problem and, um, so actually like basically you want error bars on all your predictions ideally, and how you come up with those error bars is, uh, is actually kind of an interesting research topic, I would say. So maybe you have a Bayesian neural network, but I can't, uh, it's really hard to to get a Bayesian neural network on a car. Many times to actually get your variance estimates, you'd have to do potentially through sampling or something like that. We can't afford to do sampling because we're compute bound. So I can't do multiple forward passes. Uh, also another way to get them is for—

Example, you have an ensemble, and the ensemble, um, you take your ensemble and you, you run every single model, and there this agreement is usually pretty good proxy for the uncertainty. But again, we can't, we happen not to be able to ship an ensemble, but that would be another way that you could do it. Um, another way you could do it is, um, suppose you have a regression problem that's, uh, you can basically train not just the, uh, regression, but you can also train, which is equivalent to training a log probability of a Gaussian. Um, okay, basically like your network normally outputs like the mu of a Gaussian. Okay, when you're doing L2 regression, it's equivalent to doing log probability with a with a Gaussian where you are fixing the standard deviation. The standard deviation is fixed and you only like regressing the mean, but you can also train the standard—

Deviation. And so, um, basically the network internally learns, um, its uncertainty about different examples, and intuitively what it comes down to is you're not just training, you're not just regressing towards your, um, your target, but you're also regressing the second piece of network is regressing the error that you're getting at every single prediction, and that actually ends up being what you would do if you are training—gosh. So basically one piece of the network is learning how far off you are in absolute value, and the other part of the network is trying to do its best. And so the first part—the second part of the network basically, uh, in cases where the network knows it doesn't know, it will usually predict a high error because it anticipates a high error. But when you keep getting something right, it will actually predict correctly that you—

Actually expect a low standard deviation, right? So that's another way to to do it as well. Uh, so I, I have several kind of related questions. So the first is: When you were talking about this new way of programming, you were saying by setting the architecture, you're, you're choosing a space in program space. What if the real program you need outside of that space you can find, you know, you'll only be able to get down to 1%. And what I was thinking about with this is something like the car with the, uh, the sticks sticking out. Like maybe you just need a more abstract notion of, you know, uh, how these—these were real-world objects and how they fit together. So you don't have to every time there's a weird edge case you have to get a bunch

Of data to you train for your network. And the other thing was, if the way you program is by giving it data, would you do something like, if you really wanted—there was some edge case that you didn't see before—maybe you'd hire a bunch of stunt men to like stand in front of a car driving on purpose and jump out simulation better. Yeah. So you guys do use simulation then? It's one of, one, one thing you could do. Yeah. Uh, there's only a number of papers, uh, uh, that actually seem to indicate that that actually works to some extent. Um, domain randomization and so on. Opening, I just had a paper on this. So they had the robotic that manipulates the, the cube or something like that.

That was a paper from Oh and Paper or something like that, and they train entirely in sim. It's kind of interesting. So it definitely like does something. Um, on your first topic, the correct program may sort of be outside of the blue area, and uh, yeah, exactly. So, um, I mean obviously the code that you would write in C++ that's why I'm like writing it outside because these are neural networks looking programs, and the C++ programs almost certainly don't look like neural networks-like programs, have very different properties, are much harder, sort of in their boundaries and so on and may not help, etc. Um, so I think what, what's really interesting is there's, um, so for example, you look at, um, like different neural network architectures, actually will cover different sets. So for example, there's

the neural Turing machines and stuff like that. Those actually have slightly more algorithmic components that actually can learn kinds of functions that a multi-layer perceptron will probably not be able to learn. Uh, recurrent neural network and stuff like that would be another example. There's a neural arithmetic logic community paper from four days ago. Also kind of like they're playing around with the architectural components. And, um, you really want to—what you really want to do, right, is you want to guess at where the solution to your program, where your solution program kind of is, and then you're obviously not going to be able to like write that program. So in programming 2.0, you kind of want to get a network architecture that covers it but it's as small as possible. So you want to kind of like write a little bit of the code but leave some blanks. It's like a fill in the blanks programming is the is the word I use. So you want, you

want to guess at the kind of computation you should do in that case, but then you want to leave some lengths in there which are quite automatic usually. Um, and so the neural architecture NeuroArithmetic Logic Unit is a good example of that because they kind of like bake in addition and multiplication in a certain interesting way through the architecture, but they leave some blanks in for weights and then they train it on the data. And so, yeah, I think it's really interesting because obviously you want this set to be small because then you need less data to find the solution. If you make a very large set then in principle your, your solution might be there, but you probably need much more data potentially to actually like find it and constrain it. Do we maybe not know the correct architecture for real, like, getting a self work?

Yeah, I think it's a, it's a fascinating question because like where's the solution if, if any. Um, certainly humans have an approximate solution and that's a neural network. Um, I got you talked about data set being images sequence like a video of saying here's, here's one image and then here's the success of one intent of talking to. Yeah, totally. So, um, so with respect to video I was actually kind of like burnt on this a little bit, so maybe I can tell a fun story from from Google from 2013 because I was one of the first people kind of, um, at Google to to look at, uh, training video networks. So this was 2013. AlexNet just started to work on ImageNet. Super exciting. Everything was

wide open and I was training YouTube classification, um, networks basically to distinguish types of sports and videos on YouTube. And, um, so what we did is we basically took an AlexNet lock network and we tried various approaches for extending it in time to take advantage of video information. And, uh, this was actually a little bit, uh, it like half worked. It was extremely hard. Like I tried for 3 months pretty hard to squeeze out any juice from that video, and the single frame baseline was extremely strong and I took it took it was basically really tricky to actually beat it. Um, and then when I looked into it and I thought about it more, it actually kind of like made sense and was interesting in retrospect because what's going on is a lot of our classes for example were, uh, swimming versus tennis and like you really don't need motion to distinguish swimming and tennis like a single frame it's obvious a single frame

model would be working better. And so what you're doing when you introduce video, and you intro, you basically introduce 10 million extra weights, uh, to give it power to extract motion features. But the extra delta of bits of information towards your task is like is tiny. The extra signal you're trying to go after is tiny. So you've expanded the model capacity by a lot, but you're literally only squeezing like the last few percent and that just leads to overfitting. Um, because you've given the network way too much power and you don't have that much data to actually find those correct feature presentations. And so for example, what worked really well in that case was not actually learning the whole thing. Actually, what ended up working well in that case was actually using optical flow pre-processing, uh, as a first layer. And then there was a comment on the optical flow and that

Actually, when you concatenate with image information, it actually worked really well, really fast. And so it's interesting because the network that I was training from scratch, in principle, could extract optical flow-like features and like chose not to because the optimization problem was somehow too hard. Like you can get to like 90-something percent accuracy, and then the last few percent were not enough to build the whole optical flow stack. So the human had to come in and be like, actually, optical flow is useful, trust me. And that was like some kind of a, you know, constraint, and that the network actually like picked up on the optical flow and was able to actually improve things. Uh, so that's kind of like really fascinating. So I was burned on video, and you have to be very careful that, um, the kinds of problems you're trying to solve with video actually require video. Luckily, in self-driving, that is actually

the case in many, in many settings. Uh, but uh, perhaps not enough potentially in some cases, uh, because certainly single frame models can do extremely well, and now you're looking at a small fraction that actually do require video. Um, and so you just need to be careful that you have enough of them to actually learn correct features when you introduce all the new capacity. Uh, so I just learned to be very careful with videos, and I just think through it. But in general, basically, you're completely right: video would absolutely help. Uh, just, uh, I like to do all the intermediates first, so try the optical flow and then try stand. And how do you extend is an interesting question and make sure that extending it can actually help you a lot; otherwise it won't be found by the optimization. Who are the labelers and how do you

keep them motivated? So I actually, um, I actually think like labelers are, uh, uh, they actually, uh, they actually really enjoy the work, I think. Um, so they certainly like seem happy when I go, when I go there. And, uh, I think it's because, I mean, they are literally programming the autopilot. When you put bounding boxes around things, you're telling the computer how to, how to act in those cases. Like, these are the things to worry about in the world. This is where to drive, etc., where you can drive. And so I think, uh, it's literally the case that in that image when you put a label of a car here or there, at test time, whenever the network stumbles by a similar image, that's what it's going to think about that image, right? Um, so I actually think that they

um, what really helps is, um, just getting across the point that they are actually like programming the autopilot and we're just helping them out. I think this is the correct way to do it, and I think it's, uh, yeah, I think they, they enjoy it. I certainly think that's where all the action is. So, and um, by the way, it's extremely hard because these delivering documentations, as I mentioned, they can be up to 40 pages, and they're tricky. Edge cases are tricky. So, they actually need to work closely together; they need to be very accurate, and it actually ends up being like pretty interesting. Go ahead. Um, uh, you mentioned how error analysis is really critical when it comes to improving the model itself. But I was wondering, like, in a deployed setting when, uh, the car behaves in a

different way or if there's an accident, how is the analysis done for such cases and we really backtrack and to what extent do you backtrack to? I don't think, I think this is like a very Tesla-specific question. I was hoping not to make this too much about Tesla. This is just about data engine, etc. Um, yeah, but yeah, we have an ability to go backwards and forwards in time based on the logs we save and stuff like that. Go ahead. When you do update a labeling specification, how do you know which samples need to be updated and which don't need to be updated? Um, I see. So, when we do the updates label documentation, what is that kind of like controlled by or like how we make those decisions, right? Because you, you could go back and look at every sample that you previously

labeled, but probably not all of them are affected by the update. Yeah, it's a very interesting, uh, question. So, for example, here maybe, um, you know, this image comes to me. Let's say this image comes to me and I'm like, "Oh crap, there's not in documentation. Everyone's confused." Okay, actually we should, uh, we should label through it and then we'll worry about it later in the 1.0 code downstream. And let's do that. And then, you know, a couple 10,000 images come in and then maybe at test time we actually run into problems with it because the control algorithm can't quite deal with it very well. And then I decide, actually, I think the network is perfectly capable of interpolating. So let's try to interpolate from now on and try to, uh, move that code from 1.0 stack to 2.0 stack. It's our problem. And then suddenly your images are mislabeled. And

I think, um, you can certainly imagine tooling. There's a few ways we've thought about doing this where you fix one example and then you can try to retrieve examples that look like it and have the previous label. Um, and, uh, we've, um, we're like looking into similar things. I, I don't have like a ready answer, but I can definitely imagine how AI could, like, help you source and help you with the related task. It requires infrastructure. I got, are you guys using any off-the-shelf software for your labeling or is it all built in house? I know you had that screenshot. I don't know if that was your real product or what? Uh, screenshot of, oh, the Photoshop one look like of a I don't know, all kinds of stuff going on, but it was the labeler screenshot.

Oh, I'm not sure which one. Um, but basically, uh, yeah, we do use quite a bit of our tooling just because this is such a bread-and-butter system. It's so incredibly important to us that it's—it's scary for me to, um, to delegate somewhere else. Um, just because the neural network accounts for most of the FLOPs in the vehicle, and the neural network is entirely resulting dataset and like the script, uh, for you know, import your favorite delivery is. Um, and, uh, and training, and okay, I'm obviously there's more to that and a couple thousand lines of Python, but, uh, the dataset really is what makes the autopilot to a large extent, uh, so maintaining all this infrastructure is really, like, very important to the team and, uh, so it's

really tricky. And so when I talk about, you know, the new GitHub and how we build IDs 2.0, it's actually like, um, it's not solved in my mind exactly what those products are and how companies can take advantage of them, how you can make this generic. Uh, so for example, if there, um, because all of the—the different machine learning applications will look a little different, and so what is the one piece of code that, um, people could plug and play open source so that it's useful, so that all the things I talked about modeling up things and so on and helping you by loss, um, like how do you make that generic so that anyone can drag and drop it around or license it or build on top of it? I think it's a—Yeah, it's interesting. It's not obvious, I would say. Go ahead.

So, do you think most, like, as we have more AI, uh, like deep learning networks out in the wild, um, it would be more driven to get more data through mechanisms like you do? Like, I don't know if that would be the case with, like, you know, apps or different domains. Do you think that would be similar or like it'd still be a little hard to get data for different cases? I don't know. Oh, I see. Like you're asking how, like, how often is it the case that you have this property that you can ingest a lot more unlabeled data and choose, um, you think that would be the case with other domains? I

I suspect it would be, but, uh, so I suspect it would be. Um, yeah, I don't know, sorry for your data. You seem to kind of focus on, um, like sailing features that are metatic, but like for those of us who drive, oftentimes we take the queue of our, like, neighbor cars, like in this case, even if it's like that. But if the person in front of me goes straight, I likely so, um, I mean, I guess data labeling is important, but oftentimes is also like the adaptive behavior that is, you know, is exhibited when it's during deployment

because that's also your data and maybe that should be weighted heavier then. I see. So I'm struggling how to make a more generic question out of it, but in the case for us, um, um, certainly what I focused on is human-annotated data. A lot of our data is automatically annotated as well because we see how people drive in any circumstance. So we basically have full record of what happens. And then a person drives in this way, and we have infinite data of it. And so, um, so we can, I think, get at what you're doing and mimic humans and how they drive. Uh, I don't know how to make this like a more generic statement about applications because I—I think in this, in this case, we're slightly more specific than that.

Um, yeah. So you talked about, like, human engineering to limit your, like, solution space for, like, the video classification example, and you not also mentioned about how, um, for like some problems where your dataset is something that's not like a dataset similar to something well studied like the roads aren't—don't have the same statistics as ImageNet data. So you use like neural architecture search. How do those two compare with like using human ingenuity to eliminate solution space or just having a phrase? So it's kind of interesting because, so there's a number of architecture search papers that have come out recently.

What's kind of tricky about that is, you know, you're not—when you're really doing architecture search, you're growing that blue thing by a bit, but not you're not covering the whole space. So me using optical flow in the first layer is like way out there outside of distribution, right? That's not something that's in possible for the architecture search to discover. And, in fact, this was, this was a bit of like a criticism of some of the recent papers, because the search space for the architectures are actually like pretty small in some cases, um, because you've have. Yeah, so I think, I—the trick basically is that the architecture search only gets you so far, and for some of the bigger moves you still need human ingenuity, and I think it's taking a while for an architecture search to discover that optical flow is a good thing to put in

the first layer. Right. So it's incremental progress in in growing this. Yeah. Go ahead and back. Do you see part of the software moving to hardware or A6? Do I see part of software 2.0 moving to hardware A6? 100%. And that's because, um, at least in case of neural networks, um, I think there's so much room for optimization basically compared to what what the current, um, um, computational tools, um, look like. So, for example, before, I mean, I remember writing a bunch of neural net code before GPUs were—this was all MATLAB, CPU RBMs, and CPUs are, of course, really not the best and GPUs are

Much better, but still not optimal, and that's why you see so many ASIC companies actually trying to even more specialize, thanks to neural network workflows. Um, there's a lot that can be done there. Um, for example, one memory local: a lot of the DRAM accesses, load and write, are extremely energy expensive — much more, like 100x than any single floating point operation. And so, for example, in some of the recent networks, uh, for example, using depth-wise convolutions and stuff like that, that we're going towards, which happen to work empirically fairly well, their intensity is very small. And so actually, this is really bad for CPUs, when you have to fetch all this stuff from memory and then you use it like five times, and you have to like write to memory, it's like do worse. So I think a lot of people are thinking around how you design hardware that is much more well-suited to these workflows, um, because GPUs are

surprisingly good, even though they were, you know, designed for rendering initially. Uh, but I think certainly not optimal. And so what you're seeing also from Nvidia is they're putting in things like tensor cores and stuff like that. So they're building in smaller, you know, pieces that are much more specific but keeping around some of the general infrastructure of and the approach of CUDA and the programming model there, etc. So, it's kind of really interesting what's happening in the space, but certainly we're nowhere near optimal at running neural networks close to physics. Uh, I think there's a lot to be done there. How do you see the AI challenges changing, say, when you've got the majority of cars on the road that are self-driving? Um, yes. So, if you have majority of the cars on the road self-driving, how does this change? How does—yeah, I'm envisioning thousand-car pileups. So, certainly I think it will unlock

like some interesting opportunities. We think about— we're starting to think about this because we have a pretty good, like, when you look at how many—there's a lot of Teslas on the 280 or something like that, for example, running. So we actually control like some fraction of vehicles. You can actually look into the next stack of autopilot, potentially, which is like a fleet-wide autopilot—like how do you coordinate traffic flow, etc.? Um, there's actually a really cool work from here from Berkeley on, suppose you control 5% of the vehicles, can you improve, uh, throughput of traffic? And you actually can because your cars can basically become like these shepherds of other vehicles; they slow them down. So you can actually do stuff like that. I think it's really cool. Um, so from that perspective, it's very exciting. Um, but from some other perspectives, actually, like having human drivers around is actually extremely helpful, uh,

for some of the autonomous vehicles where they're not perfect. Because, for example, the person in front of us modulates our longitudinal velocity. Uh, so that's actually we're inheriting their speed, right, because we're behind them. So we don't actually have to have perfect longitudinal profile. And of course, if they're not there, that actually increases the complexity of the problems. Uh, so if you have autonomous vehicles and autonomous these vehicles, then it actually makes the problem harder to some extent because you don't have humans actually doing the shepherding. Uh, yeah, uh, yeah. Um, there's about three and a half million truck drivers on the road right now. Um, and sort of job killing is one of machine learning's, uh, biggest factors, uh, moving forward. So what is your take on, um, self-driving

cars eating engine? Um, yeah, I think this is definitely not related to data engine. It's, um, yeah, it's an interesting question. I think, uh, empirically it's certainly the case that technology has kind of shifted jobs around and hasn't, like, really, you know, um, had a major impact on, like, unemployment rates or something like that, at least historically since the technological revolution. So I think I'm, uh, positive from that perspective.

From YouTube captions, lightly punctuated for readability. Timestamps link to the video above. Errors are possible.

Cite this recording

Andrej Karpathy, “Software 2.0: Data Is the New Code (2018)”, conference keynote / industry talk, February 2018. Transcript and video: Thinkers Archive, https://thinkersarchive.com/andrej-karpathy/software-2-0-full-stack-deep-learning-2018/

Quoting a passage? Link to its exact moment: every timestamp above has its own anchor (for example https://thinkersarchive.com/andrej-karpathy/software-2-0-full-stack-deep-learning-2018/#t-131).

Search every transcript
Open the full search page →