Learn

Learning preferences

Make learning more comfortable. Changes apply immediately.

Enlarges page content, including diagrams and their labels. You can also use your browser’s zoom.

Choose the colours that are easiest for you to distinguish. Applies to lesson diagrams and lab plots. Labels, shapes, hatching and line patterns also distinguish meanings. Source photographs and raw image brightness stay unchanged; mask-only views are available for image overlays.

ExampleComparisonSample link

Saved in this browser on this device. Preferences are separate from progress backups.

Lesson 13 of 21 in this unit

Build AI Systems · ORIGINAL LEARN AI LESSON

Learn continuous dynamics.

Collect cart transitions, fit a next-state predictor, and compare it with simpler baselines.

By the end: Fit a dynamics predictor using training episodes and compare its one-step errors with persistence and a linear model on separate development episodes.

Start with the exampleJump to the experimentRead the explanation
Prerequisites and path options

Why learn this? Learn what a prediction model gains from collected motion and when a simpler baseline already earns its place before adding planning cost.

01 · TRY

Start with something concrete.

A cart is moving left while you push it right. Predict its velocity one tenth of a second later. A model needs both the current motion and the applied action; a photograph of position alone is not enough.

Try the interactive model
02 · PREDICT
Before you experiment

You collect only gentle pushes, then use the model for much stronger pushes. What does low training error establish?

You collect only gentle pushes, then use the model for much stronger pushes. What does low training error establish?
03 · EXPERIMENT

Change one thing. Watch what follows.

Loading this browser experiment…

04 · UNDERSTAND
READ & CONNECT

Understand what changed.

Back to the experiment

A shorter explanation, with the original worked examples available below. Both explain the same experiment and its limits.

Same learning goal in both modes: Fit a dynamics predictor using training episodes and compare its one-step errors with persistence and a linear model on separate development episodes.

The idea in everyday terms

Imagine pushing a cart. To predict where it will be next, you need to know where it is, how fast it is moving, and how hard you push. A world model learns this change from examples. It predicts what an action will do; it does not choose the action yet.

What to watch in the experiment

Collect eight short training trips. Four different trips supply development examples. Compare three guesses: nothing changes, a fitted straight-line rule, and a small neural network. Train the network, then check both position error and velocity error. A tiny position error can hide a poor prediction of speed.

Try gentle pushes during collection while keeping stronger pushes in development. The model has less evidence about the stronger actions. Switch to linear drag too: the simple fitted rule may already solve most of the prediction problem. There is no requirement for the neural network to win.

Keep the comparisons honest

The optional noise changes training target measurements only. It does not change the cart’s true motion or the development answers. Each plotted prediction starts from a true state. The graph is not a long imagined journey, because predictions are not fed back as inputs. Values outside the fixed graph limits are counted and remain available numerically.

What this does not establish

These fictional trips are repeatedly visible practice. Low error does not prove useful planning, physical safety or performance on all carts. Record the data, errors and fitting work before deciding whether the extra model is worth using. Export your temporary experiment if you want to keep it. The complete calculation and assumptions are in the worked reference below.

Open the full worked examples, calculations and limitations

This is the same reference used in Technical mode. Expand it whenever you need the exact numbers, assumptions or further explanation.

A model of change

A state records what we need to predict the next moment. Here it contains position x in metres and velocity v in metres per second. An action is an applied force u in newtons. A transition records all three inputs and the next state after 0.1 seconds. Predicting a transition is supervised learning: the next state supplies the target.

Position alone is insufficient. Two carts can pass the same mark while moving in opposite directions. Giving the model velocity distinguishes those situations. We supply exact current states in this lesson; estimating them from noisy sensors is a different problem.

The teaching environment

The fictional cart has mass 1 kg. Its discrete rule is:

a=u−0.2v−qv∣v∣,v′=v+0.1a,x′=x+0.1v′.a=u-0.2v-qv|v|,\qquad v'=v+0.1a,\qquad x'=x+0.1v'.

Here a is acceleration in metres per second squared. The linear drag coefficient is 0.2 kg/s. The optional quadratic coefficient q is 0.6 kg/m, or zero in the linear setting. The prime means “next value,” not a derivative. Velocity updates before position. This is a defined discrete simulator, not exact integration of continuous mechanics.

For x=0.3, v=-0.5, u=1.2 and quadratic drag, acceleration is 1.2+0.1+0.15=1.45. The next velocity is -0.355 m/s and next position is 0.2645 m. The cart is still moving left even though its acceleration points right. The predictor must learn that relationship from collected transitions; it is not handed these coefficients.

Collect episodes, not shuffled answers

An episode is a short trajectory starting from a specified state. Eight training episodes supply 96 transitions. Four other starts supply 48 development transitions. Every episode has twelve steps. We assign episodes to splits before generating any rows, because neighboring rows share states and are correlated.

Broad collection applies forces up to ±2 N. Gentle collection applies up to ±0.25 N. Both development settings retain the same broader actions. Compare coverage by changing the collection setting and collecting again, rather than silently adding development rows to training.

The optional deterministic measurement perturbation changes only training next-state labels, by at most 0.01 m and 0.01 m/s. Current-state inputs and underlying motion remain exact. This is an isolated target-noise experiment, not a complete sensor-noise simulation. Reusing these public development episodes to choose settings makes them development evidence, not an independent final test.

Three predictors, the same evidence

Persistence predicts that position and velocity stay unchanged. It has no fitting cost. At a short horizon it can be competitive, so beat it before celebrating a small error.

The linear baseline fits two affine rules for state changes from the same training rows. Its four inputs are scaled position, velocity, force and a constant. A small ridge term of 10⁻⁶ on every coefficient stabilizes the solve. Linear drag produces a linear discrete transition, so this baseline can be particularly strong. No rule says a neural model must win.

The neural predictor uses three inputs, six tanh hidden units and two linear outputs: (3+1) × 6+(6+1) × 2=38 parameters. It predicts changes rather than whole next states. Each position change is divided by 0.2 m and each velocity change by 0.2 m/s when constructing training targets. Inputs use fixed scales of 2 m, 2 m/s and 2 N; these are declared unit scales, not statistics fitted on development data.

Inspect the learning objective

Let eₓᵢ and eᵥᵢ be the two normalized change errors for training row i. With N=96, the objective is

L=12N∑i=1N(exi2+evi2).L=\frac{1}{2N}\sum_{i=1}^{N}(e_{xi}^2+e_{vi}^2).

The factor averages over rows and halves the sum of the two squared errors; it does not average over outputs again. Backpropagation accumulates both output contributions at each shared hidden unit. All 38 weights use gradients at the preceding checkpoint, then update simultaneously at rate 0.08. A worker batch contains at most 25 updates and a run at most 1,000. A one-update CPU control remains available. Canceling or leaving the visible lab retains the preceding completed checkpoint.

Read the comparison correctly

The table reports mean absolute position error in metres and velocity error in metres per second, separately. Both training and development diagnostics compare with exact simulator outcomes; the normalized training objective compares with the possibly perturbed training labels. Those are different measurements and need not move together.

The plot uses fresh true inputs for each row. Connecting points across episode boundaries is only a display convention. These are one-step predictions, not a rollout in which predicted states feed the next prediction. Fixed velocity axes clip values outside ±2 m/s and disclose how many; the inspector and export retain exact numbers.

A small position error does not imply accurate velocity, long-horizon prediction or successful control. Before using this model to choose actions, test free-running rollouts and compare controllers under matched scenarios and explicit work budgets. Those are subsequent Course 12 tasks.

Make a decision from evidence

Record which data you collected, how the three models compare, which errors remain and whether neural fitting earned its cost. Try linear drag and gentle collection as separate interventions. Keep an unsuccessful run: it may explain why coverage or a simpler baseline matters.

Captures and exported checkpoints are temporary practice records. They are neither authenticated training histories nor independently reviewed implementations. The lesson check, later project assessment and human review are distinct forms of evidence.

05 · APPLY
Check your understanding

A predictor has 0.01 m one-step error on separate episodes. Which claim is justified?

A predictor has 0.01 m one-step error on separate episodes. Which claim is justified?
06 · CONTINUE

Take this idea with you.

Learn dynamics from state/action transitions, split by episode, and make simple baselines earn their place. Good one-step prediction is evidence for a specific dataset, not proof of useful imagination or control.

My Learning
Explore related topics and the topic map

How this topic connects

Explore this topic on the interactive map

Use these connections to review a foundation or choose where to go next. You can open any topic without completing the others.

What it builds on

  • Predict with a world model

    Anticipate the consequences of actions and know when a plan needs new observations rather than more imagination.

  • Correct errors using feedback

    Understand how repeated correction can reject disturbances or cause oscillation when delayed or too aggressive.

  • Send the error backward

    Trace a wrong update to its source so you can debug learning code and distinguish calculating gradients from changing weights.

You are hereLearn continuous dynamics

Collect cart transitions, fit a next-state predictor, and compare it with simpler baselines.

What it enables