Lesson 17 of 21 in this unit
Predict in a compact representation.
Learn a small visual code and test whether predicting that code retains useful action information.
By the end: Compare reconstructive and explicitly anti-collapse latent objectives on generated moving-shape sequences, then inspect pixel reconstruction, representation spread and action-relevant position evidence separately.
Prerequisites and path options
Why learn this? Test whether a compact visual code preserves the information an action needs instead of trusting low prediction error alone.
Start with something concrete.
A picture contains a moving object and a static patterned background. If you can keep only two numbers, which details should survive? A code that remembers the background may be easy to predict but poor at describing what an action changes.
Try the interactive modelEvery image is encoded as [0, 0], and the predictor always outputs [0, 0]. What is its latent prediction error?
Change one thing. Watch what follows.
Loading this browser experiment…
Understand what changed.
A shorter explanation, with the original worked examples available below. Both explain the same experiment and its limits.
The idea in everyday terms
Imagine describing a picture using only two numbers. Which details should survive if you need to predict what a push will change? A model that remembers a static background may be easy to predict but poor at describing movement.
What to watch in the experiment
Train three objectives on the same tiny moving-spot scenes. One learns to reconstruct images as well as predict the next code. One only predicts the next code. The third adds a penalty when codes vary too little or their two coordinates repeat the same pattern. Use the same update budget and compare more than one score.
Load the collapsed control: every image becomes the same two zeros. Prediction error is zero because the next code is also zero, but no scene differences remain. The spread penalty notices this failure through a positive loss. A perfectly symmetric zero model can still have zero gradient, so reset to the seeded model before expecting learning to escape it.
Keep usefulness separate from appearance
A separate diagnostic rule learns to read position and pixels from training codes. It never changes the encoder or action predictor. It checks development examples and predicted next codes using the same fitted rule. Compare its next-position error with keeping the current code unchanged. A poor simple readout does not prove that no other decoder could recover the information.
Add static brightness and texture, then change the probe action without changing the observed picture. Varied codes and low prediction error may still miss useful action information. The image preview clips invalid brightness values only for display and counts them; the numerical evidence keeps them. The code plot has fixed axes.
Keep the evidence in context
These are 48 training pairs and 24 public development pairs from separate short episodes. Nearby frames are correlated. Diagnostic fitting is additional work, not representation training. The neural pixel decoder is trained only by the reconstructive objective. Captures are temporary until exported; these comparisons are not independent assessment, hidden-state tracking or policy learning. The worked reference below gives the exact losses and assumptions.
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.
Pictures, codes and action predictions
A latent representation is a learned internal description rather than the original measurement. Here an encoder compresses a sixteen-pixel picture into two numbers. A predictor receives those two numbers and an action, then predicts the next picture’s code. A decoder can map a code back to pixels, but predicting a useful code does not inherently require generating a picture.
The generated scene is a soft spot moving horizontally in a 4×4 frame. Actions −1, 0 and +1 move its horizontal position by −0.18, 0 and +0.18 scene units; the position is clipped to ±0.9. Optional brightness and checker texture stay fixed within each episode. They change appearance without changing the motion rule.
Eight six-step training episodes supply 48 pairs. Four separate development episodes supply 24. Whole episodes are assigned before training, and adjacent frames remain correlated. These are tiny authored scenes, not camera data or evidence about arbitrary videos.
I denotes an image, z its two-number code and u the action. The same encoder processes both frames. Gradients from both sides accumulate into its shared weights. The predictor sees neither the future image nor the simulator’s position labels.
Why a low error can mean nothing
Suppose every image becomes [0, 0]. A predictor that always returns [0, 0] perfectly matches every next code, even when the physical object moves. This is representation collapse: different observations lose their distinctions.
Prediction-only training minimizes the mean squared difference between predicted and next-image codes. Both encoder outputs are allowed to change. The loss can decrease by making motion easier to predict, but it can also decrease by making all targets similar. The collapsed control in the lab actually sets all weights to zero; its zero loss is computed, not a fabricated score.
Compare three concrete objectives
Let L be mean squared next-code error across pairs and both code dimensions. Let R be mean squared reconstruction error across both images in each pair and all sixteen pixels. Reconstruction-plus-prediction trains the encoder, predictor and sigmoid pixel decoder to minimize L + 10R. The factor ten is an authored scale choice for these small normalized images, not a universal recipe.
Prediction-only minimizes L and leaves the decoder inactive. The third mode adds explicit terms that discourage constant codes and redundant coordinates. It also leaves the pixel decoder inactive.
To calculate V, pool the 96 source/target training encodings. For each coordinate, find its average, average the squared distances from that average, add 0.0001 and take the square root. This is the displayed regularized spread. Penalize the squared amount by which it falls below 0.3, then average over the two coordinates. A perfectly constant code therefore reports 0.01 rather than zero because of the added number.
C is the square of the off-diagonal population covariance: average the product of the two centered coordinates, then square it. It discourages the two coordinates from varying together. Low covariance alone does not establish independence or useful task information.
Here M = 96 during training. All moments use divisor M. This is an action-conditioned teaching experiment inspired by variance/covariance regularization, not a replication of the VICReg paper. It uses squared shortfall, pooled temporal views and a learned action predictor with its own specified weights and limits.
A penalty is not a guarantee
The exact zero control has L = 0, V = 0.29² and C = 0. The spread objective is therefore positive. Yet every centered code is zero, so the corresponding gradients at that perfectly symmetric point are zero too. Reset to a nonconstant seeded initialization to explore learning. The objective discourages collapse without guaranteeing escape from every initialization.
Even varied codes can encode the wrong thing. Static texture is easy to predict because it stays unchanged. With two coordinates and several sources of variation, the model can trade motion information for appearance information. Healthy spread, low prediction error and visually plausible reconstruction are not interchangeable evidence.
Inspect information without leaking it into training
A separate diagnostic readout asks what a simple affine rule can recover from the frozen codes. It fits position and pixels on the 96 training encodings only, with ridge 0.0001 on its two slopes and no penalty on its intercept. Position labels never update the encoder or predictor. Re-fitting this readout after a checkpoint is diagnostic work, not an additional representation-training step.
The same readout evaluates development encodings and predicted next codes. Compare current pixel error with a training-mean image; current-position error with next-position error; and action-conditioned next-position error with keeping the current code. A limited affine readout can miss information that a more flexible decoder could recover, so its error is not proof that all information is absent.
The neural pixel decoder’s error is reported separately and only in reconstruction mode. Its absence in the other modes must not be mistaken for a failed trained decoder. Image previews from the diagnostic readout clip brightness to 0–1, count clipped values, and preserve exact unclipped values in metrics and exports. Codes use fixed ±1 plot axes; latent coordinates are not physical coordinates.
Make a controlled comparison
Use the same initialization and update budget across objectives. Add distractors as a separate intervention. Change the probe action while holding the observed frame fixed, and inspect the true next frame, predicted code and position readout. These counterfactual probes never train the representation.
The encoder has 34 parameters, the action predictor eight and the decoder 48. Simultaneous full-batch SGD uses rate 0.3, at most 25 updates per worker batch and 1,000 total. Larger requests commit complete batches and can be cancelled. One direct CPU update remains available. Six temporary captures retain settings, weights, diagnostics and bounded notes; reload clears them unless exported.
This lesson studies one-step representations. It does not yet estimate hidden state across occlusion, train a policy in imagined trajectories, or establish independent proficiency. The fixed development examples and diagnostic labels are public practice; later project assessment and human implementation review remain distinct.
A code has healthy spread and low next-code error. What still needs testing?
Take this idea with you.
A useful latent model needs more than a small prediction loss. Separate reconstructing pixels, avoiding constant encodings and preserving information needed for action; test each with its own evidence.
Explore related topics and the topic map
How this topic connects
Explore this topic on the interactive mapUse 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
- Learn continuous dynamics
Learn what a prediction model gains from collected motion and when a simpler baseline already earns its place before adding planning cost.
- Compress and reconstruct
Inspect what a compressed representation keeps and loses before using it for another task.
- Learn from relationships between examples
Use paired examples to learn representations while checking whether the pairing teaches the intended relationship.
Learn a small visual code and test whether predicting that code retains useful action information.
What it enables
- Remember what the current view hides
Recognize when memory helps an occluded prediction and when missing information makes a single confident answer unjustified.