Skip to the lesson
FixTheRobot Home / VLA / Prerequisites / M6.1

VLA · Prerequisite · Robot Learning Fundamentals

M6.1 — Supervised Learning

Learning a mapping from inputs to targets using labelled examples.

  • Prerequisite module 6
  • Robot Learning Fundamentals
  • Learn along the way
  • About 13 minutes to read

A VLA is trained by supervised learning: given an observation and an instruction, predict the action a demonstrator took. This lesson covers the plain idea first, on regression and classification, and the one thing that decides whether it works: performance on examples the model has not seen.

Learning objectives

After this lesson, you should be able to:

  • Define supervised learning, inputs, labels and the two basic problem types.
  • Fit a line by least squares and read the error.
  • Describe logistic regression and its cross-entropy training.
  • Distinguish underfitting from overfitting using training and held-out error.
  • Explain why label noise sets a floor on error.
  • Name where labels come from in robot learning.
  1. Labelled examples: inputs with correct outputs
  2. A model makes predictions
  3. A loss compares predictions with labels
  4. Training adjusts the model to reduce the loss
  5. The test: does it work on new examples?
The supervised learning loop, and the question that matters at the end.

The one-sentence idea

Supervised learning fits a model to labelled examples so that it predicts the right output for new inputs it has never seen.

Fit the data you have, to predict the data you will get.

Learning from examples with answers

In supervised learning you have a collection of examples, each an input x paired with the correct output y, often called the label or target. The goal is a function that predicts y from x well, not just on the examples you have but on new ones. Everything in M2.4 and M2.5, a model, a loss, gradients and a training loop, is how supervised learning is carried out. This module takes that machinery and points it at robots.

Two kinds of target define the two basic problems:

Regression
The target is a number or a vector of numbers. Predict a joint angle, a distance, an action. Usual loss: squared error.
Classification
The target is one of a fixed set of categories. Predict an object class, or the next token. Usual loss: cross-entropy (M3.5).

This matters directly for VLAs: a model that predicts an action from an observation is solving a supervised problem, whose “label” is the action a demonstrator took. That is the idea of M6.2.

Regression: fitting a line

Take data from the line y = 2x + 1 with noise added. A linear model ŷ = w x + b has two parameters. Because the loss is a squared error and the model is linear, the best w and b have a direct solution, least squares, which is a matrix computation (M1.1). Gradient descent would reach the same answer, as M2.5 showed:

import numpy as np

rng = np.random.default_rng(0)
x = rng.uniform(-1, 1, size=50)
y = 2 * x + 1 + rng.normal(0, 0.1, size=50)          # the true line plus noise

A = np.column_stack([x, np.ones_like(x)])            # a column of x values and a column of ones
(w, b), *_ = np.linalg.lstsq(A, y, rcond=None)
print(round(w, 2), round(b, 2))
print(round(float(np.mean((A @ [w, b] - y) ** 2)), 4))   # mean squared error on the data

Output:

2.03 1.0
0.0099

The fit recovers a slope near 2 and an offset near 1, even though no data point lies exactly on the line, and the remaining error, 0.0099, is about the variance of the noise we added (0.1² = 0.01). Noise in the labels sets a floor under the achievable error. No model, however large, can predict the noise itself.

Classification: predicting a category

For two categories, a model can output the probability of one of them. Logistic regression applies a sigmoid (M3.1) to a linear score, p = σ(w·x + b), and is trained with the cross-entropy loss by gradient descent. The example has two clusters of points in a plane, labelled 0 and 1:

rng = np.random.default_rng(1)
X = np.vstack([rng.normal([-1, -1], 0.7, size=(40, 2)),       # class 0 around (-1, -1)
               rng.normal([ 1,  1], 0.7, size=(40, 2))])      # class 1 around (1, 1)
t = np.array([0] * 40 + [1] * 40)

w, b = np.zeros(2), 0.0
for _ in range(500):
    p = 1 / (1 + np.exp(-(X @ w + b)))                         # predicted probability of class 1
    w -= 0.5 * X.T @ (p - t) / len(t)                          # gradient of the cross-entropy loss
    b -= 0.5 * np.mean(p - t)

p = 1 / (1 + np.exp(-(X @ w + b)))
loss = -np.mean(t * np.log(p) + (1 - t) * np.log(1 - p))
print(round(float(np.mean((p > 0.5) == t)), 3), round(float(loss), 3))

Output:

1.0 0.017

All 80 training points are classified correctly (accuracy 1.0), and the cross-entropy loss is low. The gradient X.T @ (p − t) is the same “prediction minus target” form seen for the squared error in M2.4, which is a general property of pairing a sigmoid or softmax output with cross-entropy.

The real goal: new examples

A model that fits its training data perfectly can still be useless on new data. The danger is greatest when the model is flexible enough to follow the noise. A classic demonstration fits polynomials of increasing degree to noisy samples of a smooth curve, and measures the error both on the training points and on fresh points the fit has never seen:

rng = np.random.default_rng(2)
f = lambda x: np.sin(2 * np.pi * x)
x_train = np.linspace(0, 1, 15);          y_train = f(x_train) + rng.normal(0, 0.2, 15)
x_new = np.linspace(0, 1, 200);           y_new = f(x_new) + rng.normal(0, 0.2, 200)

for degree in (1, 3, 12):
    coef = np.polyfit(x_train, y_train, degree)
    train_err = np.mean((np.polyval(coef, x_train) - y_train) ** 2)
    new_err = np.mean((np.polyval(coef, x_new) - y_new) ** 2)
    print(degree, round(float(train_err), 3), round(float(new_err), 3))

Output:

1 0.287 0.254
3 0.047 0.043
12 0.0 0.949

A straight line (degree 1) has high error on both sets: it is too simple, which is underfitting. Degree 3 gets both errors low and close together. Degree 12 achieves essentially zero training error, because it passes almost exactly through all 15 points, but its error on new points is 0.949, more than twenty times that of degree 3: it has bent through every noisy training point and swings wildly between them. That is overfitting. The signature of overfitting is a training error much lower than the error on held-out data, which is why M6.4 makes a habit of measuring on data the model did not train on.

What supervision means for robots

Supervised learning needs labelled data, and labels are expensive to get. For robots there are a few common sources:

  • Human demonstrations. A person controls the robot (often by teleoperation), and the actions they command become the labels for the observations the robot saw. This is the basis of imitation learning (M6.2) and of most VLA training data.
  • Annotation. People mark objects in images, or write captions, which gives labels for perception.
  • Self-generated labels. The data supplies its own targets, as in next-token prediction (M3.5), or a robot’s later camera frame labelling its earlier action.

Two other learning settings are worth naming so you can tell them apart. Unsupervised learning looks for structure with no labels at all, such as clusters. Reinforcement learning (M6.6) has no correct answer for each step, only a reward signal that arrives after the fact. Supervised learning is the simplest and best understood of the three, which is a large part of why robot learning leans on it, and why the quality and coverage of the labelled data matters so much.

Common misconceptions

Misconception 1 “Zero training error means the model is good.”

Correction It can mean the model memorised the noise. Error on held-out data is what shows whether it generalises.

Misconception 2 “A more flexible model is always better.”

Correction Too flexible a model for the amount of data overfits. The right capacity depends on how much data and noise there is.

Misconception 3 “Labels are always correct.”

Correction Labels come from people and sensors and contain noise and mistakes, which limits how low any model’s error can go.

Misconception 4 “Supervised learning only applies to labelled images and text.”

Correction Any input-to-output mapping with examples qualifies, including observation-to-action in robot control.

Engineering takeaways

  1. Supervised learning learns a mapping from inputs to labelled outputs.
  2. Regression predicts numbers, usually with squared error, and classification predicts categories, usually with cross-entropy.
  3. A linear model with squared error has a direct least-squares solution, and gradient descent finds the same answer.
  4. Logistic regression is a linear score passed through a sigmoid.
  5. Underfitting means high error everywhere, and overfitting means low training error but high error on new data.
  6. Noise in the labels puts a floor under the achievable error.
  7. A VLA is supervised: its labels are demonstrated actions.
  8. The quality and coverage of the labelled data limit what the model can learn.

Everything a model learns is shaped by the examples it was shown, and judged on the ones it was not.

Knowledge check

Try each question first, then reveal the explanation.

Question 1

A model has a training error of 0.01 and an error of 0.40 on held-out data. What is likely happening, and what is one remedy?

Explanation

It is overfitting. It has fitted the training data, noise included, and does not generalise. Remedies include more data, a simpler or regularised model, or stopping training earlier.

Question 2

Your data’s labels have noise with variance 0.04. Roughly what is the lowest mean squared error any model can reach on new data from the same source?

Explanation

About 0.04. The noise in the labels is unpredictable from the inputs, so even a perfect model of the underlying pattern cannot predict it, and its error will not fall below the noise variance.

Question 3

A robot dataset pairs camera images with the joint targets a human teleoperator commanded. Is learning from it regression or classification, and what are the labels?

Explanation

Regression, with the commanded joint targets (the actions) as the labels. The outputs are continuous numbers. If the actions were discretised into bins, it could instead be treated as classification.

What’s next

You have the supervised-learning basics. Next is the special case at the heart of VLA training: learning to act by copying demonstrations.

Next lesson

M6.2 — Behavior cloning and imitation learning

Training a policy to copy demonstrated behaviour.

Back to the VLA roadmap prerequisites