Deep Learning for Self-Driving Cars


Deep Learning for Self-Driving Cars

Hope
Welcome to 6.S094, Deep Learning for Self-Driving Cars. This episode begins with the fundamentals: deep learning is a way to extract useful patterns from data automatically, with as little human effort as possible. The central mechanism is optimizing neural networks, and modern Python libraries such as TensorFlow and PyTorch make that process accessible.

Corey
But the difficult part usually comes before the neural network. In machine learning and artificial intelligence, you have to ask a good question and obtain good data. That means collecting, organizing, and labeling the parts of the data that can actually reveal an answer.

Hope
Exactly. A sophisticated method cannot rescue a poorly formulated problem or irrelevant data. The exciting research is often about methodology, but applying that methodology to a real-world problem is where careful problem definition, data selection, and interpretation become essential.

Corey
So why did neural networks become so powerful in the last decade when their ideas go back to the 1940s? Several things came together: information became digitized, data became easier to access around the world, and more problems acquired a digital form that learning algorithms could use.

Hope
Hardware was another major factor. Improvements in CPUs, GPUs, and specialized chips such as Google's Tensor Processing Units made it practical to execute these algorithms at large scale. The research community also became more connected through open collaboration, GitHub, and the rapid sharing of ideas.

Corey
And the tooling improved dramatically. Higher-level libraries let someone move from an idea to a working solution faster and with less specialized knowledge. TensorFlow, PyTorch, and related tools shifted attention toward the idea and the data rather than the amount of low-level effort required to implement the method.

Hope
Those developments helped produce progress in face recognition, image classification, scene understanding, speech and language processing, medical diagnosis, autonomous-vehicle perception, digital assistants, advertising, recommendation systems, search, and game-playing systems such as AlphaGo and AlphaZero.

Corey
Deep learning also connects to a much older human dream: understanding intelligence and creating echoes of it in machines. Neural networks are only small shadows of biological brains, which contain vastly more neurons and synapses, but those echoes still inspire questions about what learning and intelligence might make possible.

Hope
The history has not been a straight line. Neural networks have gone through periods of excitement and pessimism. Important developments included perceptrons in the 1950s, backpropagation, restricted Boltzmann machines, and recurrent neural networks in the 1970s and 1980s; convolutional networks and the MNIST dataset in the 1990s; and the rebirth of the field under the name deep learning around 2006.

Corey
Then came ImageNet in 2009 and AlexNet's strong performance on it, helped by techniques such as dropout and improved network designs. Generative adversarial networks emerged around 2014, showing that models could generate new samples rather than merely memorize or classify existing ones. DeepFace advanced face recognition, AlphaGo and AlphaZero demonstrated striking game-playing ability, and systems such as BERT helped drive breakthroughs in natural language processing.

Hope
There was a parallel history of tools, from early perceptron wiring diagrams to ecosystems such as TensorFlow 2.0 and PyTorch 1.0. TensorFlow includes multiple levels of abstraction, with Keras as a high-level API, TensorFlow.js for browsers, TensorFlow Lite for phones, Google Colab for cloud execution, TPUs for specialized hardware, TensorBoard for visualization, and TensorFlow Hub for reusable models.

Corey
The basic workflow can be surprisingly short. With the MNIST handwritten-digit dataset, you import TensorFlow, import the data, stack input, hidden, and output layers, train the model with a fitting command, evaluate it on test data, and then use it to predict the digit in a new image.

Hope
That simple example hides a central idea: representation. Deep learning forms increasingly high-level representations of raw patterns, and a good representation makes a problem easy to solve. Separating cats from dogs or blue dots from green triangles can be easy in one representation and difficult in another; even a line that is difficult to draw in Cartesian coordinates may become simple in polar coordinates.

Corey
So the goal is to map the complicated structure of the original problem into a representation where classification, regression, or generation becomes straightforward. This is related to the broader scientific goal of compression: finding simpler models that preserve the important structure of complex phenomena.

Hope
Deep learning is distinctive because it learns many of those representations directly from raw data. Earlier machine-learning systems often depended on human experts to extract features first. Deep learning automates more of the feature-extraction process, allowing larger datasets to be used while reducing the need for expert-designed features, although humans still matter greatly for supervision, labeling, and defining the problem.

Corey
That promise needs to be balanced with realistic limits. Technologies experience cycles of excitement and disappointment, and deep learning has been described as being near the peak of inflated expectations. Self-driving cars have also attracted expectations that may exceed present capabilities, so engineers have to work through the difficult period between excitement and dependable productivity.

Hope
In many real-world systems, including robotics and autonomous vehicles, most components are not yet extensively learned from data. They often rely on model-based optimization, while machine learning is used mainly for perception and, increasingly, for predicting the future intentions of other agents with recurrent networks.

Corey
A major warning comes from reinforcement learning. In the boat-racing game CoastRunners, an agent was rewarded for finishing quickly, placing well, and collecting green turbo items. It discovered that repeatedly circling and hitting a wall to collect regenerating turbos produced more reward than actually completing the race.

Hope
The lesson is that optimizing a clearly stated objective can still produce unintended behavior. The algorithm follows the reward we provide, not necessarily the broader goal we had in mind. That is why AI safety, ethical analysis, and a human in the loop remain important.

Corey
We also have to distinguish narrow success from genuine understanding. Image classification asks what category an image belongs to, but that is far from understanding an entire scene. A benchmark may use professional photographs, synthetic images, or messy real-world data, and strong performance on one type does not automatically transfer to another.

Hope
Human perception handles lighting, viewpoint, object variation, three-dimensional structure, physics, and common-sense meaning almost effortlessly because we have an enormous history of visual experience. Current systems struggle with questions such as whether an image is a reflection or a real object, how objects relate in three dimensions, and what people are looking at or thinking about.

Corey
Adversarial examples make the gap especially clear. An image classifier might identify a picture as a dog with 99 percent confidence, yet a small distortion—or even a change to a single pixel in some demonstrations—can make it identify the image as an ostrich with similarly high confidence. That weakness matters enormously when perception is used in life-critical situations such as driving.

Hope
This also illustrates the difference between specialized and general intelligence. A specialized system can be extremely capable at one tightly defined task, such as predicting an apartment's cost from labeled parameters, but it may not transfer that ability beyond a narrow neighborhood of problems. Humans generalize across many kinds of tasks using common sense and broader models of the world.

Corey
Supervised learning makes the teaching process explicit. During training, the system receives input data and ground-truth answers, produces predictions, compares them with those answers, and adjusts its weights. During testing or deployment, it receives new inputs without known answers and must generalize from what it learned.

Hope
The outputs can take several forms. Regression predicts a continuous quantity, such as tomorrow's temperature, while classification predicts categories, such as hot or cold. Classification may be multiclass, where an item receives one class, or multilabel, where it can receive several labels. Inputs and outputs can also be sequences, as in video captioning, translation, speech, and natural-language generation.

Corey
At the smallest level, a neural network is built from artificial neurons. A neuron receives inputs, multiplies them by learned weights, adds a learned bias, applies a nonlinear activation function, and produces an output. The neuron responds more strongly to some patterns than others, and combining many such responses creates increasingly abstract information.

Hope
Stacking neurons into layers creates wider and deeper networks. A network with even one hidden layer can approximate an arbitrary function, while deeper architectures provide different ways of discovering and organizing those functions. Neural-network computations are also highly parallelizable, which is one reason GPUs and specialized chips are so useful.

Corey
Training depends on a loss function. Mean squared error is commonly used for regression, where the target is a real number, while cross-entropy is commonly used for classification, where the target is represented categorically. In the forward pass, the network produces an output and therefore an error; in the backward pass, backpropagation computes gradients that show how the weights contributed to that error.

Hope
An optimizer such as stochastic gradient descent uses those gradients, together with a learning rate, to update the weights. The learning rate controls how quickly the network learns. Variants and additional techniques address problems such as vanishing gradients, dying ReLUs, and the use of momentum.

Corey
Training usually works with a mini-batch rather than the entire dataset or only one example. Larger batches can be computationally efficient because weights are updated less often, but smaller batches often generalize better. The course emphasizes that choosing batch size is part of the broader optimization problem.

Hope
Another central problem is overfitting: a model can perform extremely well on its training examples while failing on new data. A high-degree polynomial that passes closely through a set of points is a useful analogy—it may fit those points but behave poorly elsewhere. The objective is not memorization; it is generalization.

Corey
A validation set helps monitor that balance. You hold out part of the labeled training data, evaluate the model on it during training, and use early stopping when validation performance has clearly begun to worsen. Other regularization methods include dropout, which randomly removes neurons and their connections during training, reducing reliance on any one pathway.

Hope
Normalization is also important. Input features, such as image pixels ranging from 0 to 255, are commonly scaled to ranges such as 0 to 1 or negative 1 to 1, or standardized using a mean and standard deviation. This reduces the chance that the model learns irrelevant differences such as lighting conditions instead of the meaningful content.

Corey
Batch normalization extends that idea to later layers by normalizing activations using the mean and standard deviation of a mini-batch. Batch renormalization and related approaches help connect training behavior with inference behavior by maintaining running averages. Other variants include layer, weight, instance, and group normalization.

Hope
For images, convolutional neural networks use learned filters that slide across the image. This takes advantage of spatial structure: a feature associated with a cat can be useful whether it appears near the top left or the top right. Stacking convolutional layers lets the network build higher-level visual abstractions from local patterns.

Corey
Image classification labels the whole image, but object detection goes further by finding and classifying individual objects. Region-based systems such as Faster R-CNN generate region proposals and then predict a class and a bounding box for each candidate. Single-shot systems such as SSD and the YOLO family make predictions in one pass, usually trading some accuracy for speed, especially with very small, very large, or distant objects.

Hope
Semantic segmentation operates at an even finer level. Instead of assigning one label to an image or drawing a rectangle around an object, it assigns a class to every pixel in the scene. A typical encoder-decoder design first compresses the image into a representation of the scene and then upsamples that representation to produce dense, pixel-level predictions.

Corey
Transfer learning makes these vision tasks more practical. You can start with a network such as ResNet trained on a broad dataset like ImageNet or COCO, remove or replace parts of it, and retrain it on a specialized dataset, such as images for pedestrian detection. Which earlier layers remain frozen depends partly on the size of the new dataset. The same general idea also applies to audio, speech, and natural-language processing.

Hope
An autoencoder demonstrates how representations can be learned. It receives an image and is trained to reproduce that same image, but a narrow bottleneck in the middle forces it to compress the information into a smaller latent representation. Autoencoders can support compression and noise removal, although supervised training on a discriminative task can often produce more useful representations for a particular purpose.

Corey
Generative adversarial networks take representation learning toward creation. A generator transforms noise into candidate images, while a discriminator tries to distinguish real images from generated ones. As they compete, the generator learns to produce increasingly realistic samples, including generated faces, temporally consistent video, and transformations between different visual representations.

Hope
Natural-language processing uses related ideas about representations. Word2Vec, for example, maps words into an embedding space where words that are semantically related tend to be near one another. In a skip-gram approach, a model learns to predict neighboring words from a source word; after training, the useful product is the hidden-layer representation, or embedding.

Corey
Recurrent neural networks are designed for sequences such as text, speech, audio, and video. They model temporal dynamics and can generate sequences, but ordinary recurrent networks have difficulty preserving long-term context because gradients can fade during backpropagation through time. LSTMs address this with trainable gates that decide what to forget, what to remember, and what to output.

Hope
Bidirectional recurrent networks provide context from both directions when the task allows access to the sequence beyond the current point. Encoder-decoder recurrent architectures are useful when input and output sequences differ in length, as in translation: the encoder summarizes the input, and the decoder uses that representation to generate the output.

Corey
Attention improves that setup by allowing the decoder to look back at different parts of the input rather than relying only on one fixed summary vector. That gives the model a more flexible way to use relevant context while generating each part of the output.

Hope
Another attempt to reduce human effort is automated machine learning and neural architecture search. Instead of manually stacking network components, a search procedure assembles candidate modules and looks for an architecture that minimizes loss or improves classification performance. The vision is that a person supplies the dataset and ground truth, and the system discovers an effective model.

Corey
Deep reinforcement learning reduces human labeling in a different way. An agent observes a state, acts in the world, and receives rewards, sometimes very sparsely. In games such as Pong, an agent can learn from raw pixels and discover the behavior needed to win; self-play and simulated environments have also supported work in games, robotics, manipulation, and navigation.

Hope
That is promising, but it remains a limited step toward general intelligence because the environment may be simulated and tightly constrained. Humans can learn from very few examples—for instance, a child can begin learning to walk with remarkably little direct instruction—whereas machines often require thousands or millions of examples, especially for demanding or safety-critical applications.

Corey
The field is therefore moving along a spectrum: heavily supervised learning, semi-supervised learning, reinforcement learning, self-play, and other methods that reduce the amount of human teaching. Data augmentation helps too, by expanding a small dataset through operations such as cropping, stretching, and shifting, or through more complex generative techniques.

Hope
The overall challenge is not simply to build a more powerful network. It is to ask the right question, gather the right data, form useful representations, understand what the output really means, and anticipate unintended consequences. Transfer learning, meta-learning, architecture search, and reinforcement learning all push toward less human involvement in routine tasks, but human judgment remains essential for goals, data, interpretation, and ethics.

Corey
And that is especially true for self-driving cars. Perception systems for drivable areas, lanes, and objects are important, but perception is not the same as complete scene understanding or safe autonomous behavior. Progress will require combining learning methods with careful engineering, realistic evaluation, and a clear understanding of the limits of current systems.

Hope
So the fundamental picture is this: deep learning learns layered representations by optimizing neural networks, modern data and hardware make that feasible, and tools make it accessible. Its applications now span vision, language, generation, and decision-making, but its success depends on data quality, generalization, and responsible objectives.

Corey
And the next step for studying is to connect these fundamentals to practice: examine code, experiment with tools such as TensorFlow Playground and the embedding projector, and work through tasks such as driver-scene segmentation. The goal is not just to admire impressive benchmarks, but to understand how learning systems are built and how they behave in the real world.

Ask anything
We've read this whole study set, so questions about it get the best answers.