How machines learn from data

At a glance

  • Machine learning fits a prediction function to examples using a measurable loss.
  • Backpropagation computes gradients; an optimizer uses them to update the model’s weights.
  • The 2022 steering experiment used supervised behavioral cloning, with validation to assess generalization.
On this page

A machine-learning model does not need a rule for every situation. It needs examples, a way to measure its mistakes, and a process for improving.

When I worked on my Self Driving Car Project in 2022, learning to steer was only part of the exercise. Understanding why a model could learn anything at all was just as important. This article introduces that foundation; the original report develops the mathematics and the experiment in more detail. [1]

AI, machine learning, and deep learning

Artificial intelligence is the broad field of building systems that perform tasks associated with intelligence. Some systems use explicit rules. Others learn patterns from data.

Machine learning is the second approach: instead of specifying every decision, we fit a model using examples. Deep learning uses neural networks with multiple layers to learn useful representations of those examples.

Imagine trying to write every rule a car would need to recognize a bend in a road. Lighting, camera angles, shadows, and road surfaces change. A learned model instead looks for patterns across many examples. That flexibility is valuable, but it also makes the quality and coverage of the examples essential.

What does “self-learning” mean?

The phrase is useful informally, but it can hide important differences. A system that adjusts its parameters is learning; that does not mean it teaches itself without data, a goal, or human decisions.

  • Supervised learning: learn from inputs paired with target answers, such as a camera image and the steering angle a human used.
  • Unsupervised learning: look for structure without a target answer for every example.
  • Self-supervised learning: construct a training signal from the data itself, such as predicting a missing portion.
  • Reinforcement learning: learn from actions and rewards over time.

My steering experiment used behavioral cloning, a form of supervised imitation learning. It learned from recorded driving examples. It was not a car discovering a driving policy through trial-and-error rewards. [1]

A model is a prediction function

For the driving example, the input is an image and the output is a steering angle. Between them is a function controlled by adjustable values called weights. Training changes those weights so the predictions better match the examples.

Example→Prediction→Error→Adjustment

A neural network stacks simpler operations into a more expressive function. Nonlinear activation functions matter: stacking linear operations alone still produces a linear operation. An activation such as ReLU, which outputs the larger of zero and its input, lets the network represent more complicated relationships.

Loss gives mistakes a number

A loss function measures how far a prediction is from its target. For a steering angle, mean squared error is one option: square the difference between the predicted and recorded angles, then average across examples.

That number gives training a direction. Rather than asking whether a prediction looks good, we can ask whether a change to the weights reduces the chosen loss. The choice of loss still matters: a low score on a mathematical objective is not automatically proof that a complete system behaves well.

Gradient descent is a sequence of small corrections

A gradient tells us how the loss changes as we adjust the weights. Gradient descent moves against that gradient, taking steps intended to reduce the loss. The learning rate controls the size of each step.

new weights = current weights − learning rate × gradient

A step that is too large can overshoot a useful region. Steps that are too small can make progress slow. With mini-batch training, the model estimates its update from a subset of the data rather than evaluating every example before each adjustment.

Backpropagation calculates the gradients efficiently through the layers using the chain rule. It supplies the derivatives; an optimizer uses them to update the weights. They are related parts of training, rather than two names for the same operation. Pantelis Monogioudis’s CS677 materials are a useful next step for these foundations. [2]

Learning the examples is not enough

A model can memorize patterns that happen to work in its training data and perform poorly on new inputs. That is overfitting. A held-out validation set helps reveal the gap. Regularization, dropout, and better data can help, but none replaces careful evaluation.

A convolutional neural network adds a useful structure for images: filters inspect local regions and reuse the same learned operation across the image. That makes it possible to learn visual features without treating every pixel location as completely unrelated.

These pieces fit together in a practical sequence: choose a task, collect representative examples, define a model and a loss, train, and test what the model actually learned. The next article follows that sequence through my simulated-driving experiment.

References & further reading

  1. Sahil Bambulkar. Self Driving Car Project, May 20, 2022. See the mathematical introduction on pp. 3–6 and behavioral-cloning experiment on pp. 13–18.
  2. Pantelis Monogioudis. CS677: Deep Learning for the Curious Mind. Course materials on learning, optimization, backpropagation, and neural networks.
Read as Markdown ↗