← Research

Technical Report · Self Model Research · Rung 3

Surprise Has a Signature: Telling Body Change from World Event

A single qualitative demonstration that the time course of prediction error, not its size, separates “my body changed” from “the world pushed me”

Abstract

A self-model that adapts online has to decide, every time its predictions fail, whether its own body changed (and it should adapt) or the world briefly acted on it (and it should not). We test whether the one-step prediction error of a frozen learned forward model carries enough information to make that call. A CEM controller balances Pendulum-v1 using the model. At t = 4 s we either permanently lengthen the pendulum by 50% or apply a 1 N·m external torque, invisible to the model, for 0.25 s. Both events raise prediction error at onset, and the brief push produces the larger spike (peak raw error 0.164, against 0.092 for the body change), so magnitude alone does not separate them. What separates them is persistence. After the push ends, raw error is back below the pre-onset threshold on the very next step. After the body change, error is still 5.71× its pre-onset level three seconds later, against 1.06× for the push. This is one episode per condition at one parameter setting. It is a direction result, not a classifier, and it reports no false-positive rate.

Status of this result

Read this as evidence that a signal exists, not as a solved problem. Everything here comes from one seed, one size of body change and one size of push, inspected by eye and summarised with two hand-defined features. Section 4 sets out what is missing before this could support a claim about attribution in general.

1Motivation

The previous report in this series established that a learned forward model registers a change in its own body as a rise in one-step prediction error, and that fine-tuning on post-damage transitions partly restores control. It treated the rise in error as unambiguous: if the model is surprised, the body changed.

That assumption does not hold outside a controlled experiment. A robot's predictions also fail when something outside it acts on it: a push, a collision, an unmodelled load that comes and goes. If the self-model treats every surprise as evidence about its own body, it will fine-tune toward dynamics that only existed for a quarter of a second, then fine-tune back. In the meantime it plans against a model that is wrong about the body it actually has. Report 2 showed that a planner committed to a wrong model degrades far more than a reactive policy does. A self-model that rewrites itself in response to every transient makes that outcome routine.

So online adaptation needs a gate in front of it. Before deciding how to adapt, the system has to decide whether the surprise was about itself. We call this attribution, and we treat it as a precondition for safe online adaptation rather than a refinement of it. This report asks the narrowest version of the question: in a setting where we control exactly what happened, does the error signal the self-model already produces carry the information needed to tell the two cases apart?

2Setup

System under test

The forward model and planner follow the earlier reports. An MLP (4 → 64 → 64 → 3, ReLU) takes [cos θ, sin θ, θ̇, u] and predicts the change in state. It is trained with MSE (Adam, lr 10⁻³, 1000 full-batch epochs) on 2000 random-action transitions from the stock, healthy Pendulum-v1, then frozen. It is never updated during an episode, because the object of study is the surprise of a fixed self-model, not its adaptation. A CEM planner (20-step horizon, 5 iterations, 100 candidates, 10 elites) uses the same model to choose torques and re-plans every step.

The task is balance-hold rather than swing-up. Each episode starts within ±0.2 rad of upright and lasts 240 steps (12 s at dt = 0.05 s). Holding near upright gives a flat, low baseline error, so a change in the error is easy to read. Swing-up adds its own transient error bumps to every condition.

The three conditions

At step 80 (t = 4 s), one of three things happens:

The two disturbances enter through different channels:

θ̈ = 3g/(2l)·sin(θ) + 3/(m·l²)·(u + τ_ext)
# body change: l → 1.5·l (permanent)
# world event: τ_ext = 1 N·m for 0.25 s, else 0

The external torque is added after the controller's torque has been clipped and never appears in the action the model is given, so the model has no way to anticipate it. During the push the environment evaluates Pendulum-v1's equation of motion with that one extra term. At all other times it calls the stock step function. We verified that this re-implementation reproduces stock Pendulum-v1 exactly (maximum difference 0 over 500 steps) when τ_ext = 0. Length was chosen over mass deliberately. Mass enters only the torque term, so a mass change is invisible while the controller applies little torque. Length enters both terms and is visible even when the pendulum is near rest.

All three conditions use the same seed for the start state and for the planner's random samples, so the three episodes are identical up to step 80. Any difference after that is caused by the disturbance.

The surprise signal

At every step the model is given the true current state and the action about to be executed, and its prediction is compared with what the environment then returns:

e_t = ‖ s_(t+1) − f(s_t, a_t) ‖₂ # over [cos θ, sin θ, θ̇]

Because the model always starts from the true state, errors do not compound. Each e_t scores a single transition. We plot e_t raw and as a 10-step (0.5 s) trailing mean. The mean is trailing rather than centred, so the smoothed value at any step depends only on the past, which is what an online detector would see.

Two summary features are computed per episode, each relative to that episode's own pre-onset window:

An episode counts as still elevated if the late-window mean exceeds the pre-onset mean by more than four pre-onset standard deviations. Here that threshold is 0.0311. It uses no data from after the onset.

3Result

Figure 1 — Surprise signatures: body change vs world event
Two stacked panels of one-step prediction error against time over 12 seconds on a log scale, for baseline, body change and world event. The three traces coincide until 4 s. The world-event trace spikes highest during the shaded 0.25 s push, then returns to the baseline level. The body-change trace rises and stays elevated. The lower panel shows the same data as a 10-step trailing mean.
Figure 1. One-step prediction error of a frozen forward model while CEM balances Pendulum-v1, one episode per condition, log scale. Top: raw error per step. Bottom: 10-step (0.5 s) trailing mean. All three episodes share a seed and are identical until the dotted onset line at t = 4 s. The green band marks the 0.25 s external push; the grey band (bottom) is the late window used for the persistence feature. The world event (dashed) spikes highest and then falls back to the baseline level; the body change (length ×1.5) rises and stays elevated. The late climb of the body-change trace after about t = 10 s is the pendulum tipping past the angle its motor can recover from (Section 4).

Before the onset the three traces lie on top of one another, as the shared seed requires. At t = 4 s both disturbances raise the error.

World event. While the push is active, the error jumps to the highest value in any condition, 0.164 (about 15× the pre-onset mean of 0.0113). Once the push is removed the error falls back immediately. On the first step after the push ends (t = 4.25 s) the raw error is already below the pre-onset threshold and stays there, and the 10-step trailing mean rejoins the baseline trace within 0.45 s. This is what the setup predicts. The push displaced the pendulum but did not change its physics, so once it stops, the model's description of the body is correct again. The controller recovers from the displaced state, and the model predicts that recovery well because its random-action training data covered states away from upright.

Body change. The error rises to a smaller peak, 0.092, and does not come back. For the rest of the episode it sits well above the baseline trace, because every subsequent transition is predicted with an equation of motion the body no longer obeys.

The point of the figure

At onset, the brief push produces a larger spike than the body change (0.164 against 0.092). A rule based on magnitude (“large surprise means my body changed”) would therefore get this case backwards. The two events differ in their time signature. A transient cause produces a transient error; a persistent cause produces a persistent one. The trailing-mean panel makes the separation easiest to see: by the late window the world-event trace has merged with the baseline while the body-change trace remains clearly above both.

ConditionPre-onset meanPeak after onsetPost / preLate / preStill elevated
Baseline0.01130.01740.950.91No
Body change (l ×1.5)0.01130.09224.535.71Yes
World event (1 N·m, 0.25 s)0.01130.1644.091.06No
Table 1. Summary features for the three episodes in Figure 1. Pre-onset means are identical because the episodes are identical before onset. Post / pre: mean error over the 20 steps after onset divided by the mean over the 40 steps before it. Late / pre: mean error over a 20-step window starting 3 s after onset, divided by the same pre-onset mean. Still elevated: late-window mean above the pre-onset mean plus four pre-onset standard deviations (0.0311). Values are from results/summary_features.csv.

The “before vs after” feature responds to both disturbances (4.53× and 4.09×), so it says that something happened but not what. Only the persistence feature distinguishes them (5.71× against 1.06×), and in this episode it does so with no tuning on disturbed data. That is the whole of the result: a signal exists, it has the predicted shape, and its shape rather than its size is what carries the attribution.

4Limitations

A direction result, not a solved problem

What is shown is that, in one hand-picked setting, the error a self-model already produces has a time signature that separates a permanent body change from a brief external push. What is not shown is that this separation holds across trials, disturbance sizes, disturbance types or bodies, or that it can be turned into a decision rule with a known error rate. Each item below is an open gap, not a caveat on a finished result.

1

A single qualitative demonstration. One episode per condition, one seed. The features in Table 1 summarise those three episodes and nothing else. No classifier is trained or evaluated, and no accuracy is claimed.

2

One parameter setting, chosen to be easy. A large, permanent body change (length ×1.5) against a short, isolated push (1 N·m for 0.25 s). A smaller body change, a longer or repeated push, or a disturbance that persists (a sustained load, wind) would sit closer to the boundary. Where that boundary is has not been measured.

3

No false-positive rate and no detection-boundary sweep. We report no rate at which undisturbed episodes are flagged, no rate at which pushes are misread as body changes, no latency distribution and no ROC curve. The four-sigma threshold and the 3 s lag are reasonable defaults, not tuned or validated choices.

4

The body-change pendulum falls. A longer pendulum needs more torque to hold at a given angle. With l = 1.5 the motor's maximum angular acceleration is 3·2/(1·1.5²) ≈ 2.67 rad/s², against gravity's 10·sin θ, so the actuator limit of ±2 N·m cannot hold the lengthened body once it drifts past roughly 0.27 rad. In this episode it crosses that angle at t ≈ 9.4 s and is clearly falling by t ≈ 10.1 s. The late window (7–8 s) is placed before the fall, while the pendulum is still within 0.22 rad of upright, so the persistence reading is not caused by falling. A later window would partly measure a fallen pendulum rather than a changed body.

5

The norm is dominated by angular velocity. cos θ and sin θ are bounded in [−1, 1]; θ̇ is unbounded rad/s. Both disturbances here act on angular acceleration, so this does not distort the comparison. A disturbance that acted mainly on position would be under-weighted. Per-dimension residuals are saved alongside the error series.

6

A rigid pendulum in simulation. One degree of freedom, no sensor noise, no contact, no unmodelled dynamics. On a compliant body, deformation under load is itself a transient change in the body. That is exactly the case where “body” and “world” are hardest to separate, and it is untested.

7

Not a new idea in isolation. Separating persistent changes in a system from transient external disturbances is a long-standing problem in model-based fault detection and isolation. There, residuals between a model and measurements are analysed for faults while disturbances are rejected (Chen & Patton, 1999; Isermann, 2006). Robotics work on body schemas and self-modelling has studied detecting and adapting to changes in a robot's own body (Bongard, Zykov & Lipson, 2006; Hoffmann et al., 2010). This report applies that reasoning to a learned forward model used for control, and does not claim the underlying idea as new.

8

Parameter identity is not addressed. Even when a body change is detected, this setup does not say which parameter changed. On this body some changes are not separable in principle: mass and actuator gain enter the dynamics only as a ratio, so “heavier” and “weaker motor” produce identical trajectories.

5Next steps

  1. Quantify it. Turn the persistence feature into an explicit detect-then-classify rule with a threshold calibrated on undisturbed runs only, and evaluate it over many randomised trials (start states, seeds, onset times). Report accuracy on each class, the false-positive rate on undisturbed episodes, and the time to a verdict, with uncertainty.
  2. Find the detection boundary. Sweep body-change size down until it can no longer be detected, and push strength and duration up until a push is no longer rejected. The smallest detectable body change and the largest rejectable push define the operating range, and that range is the honest headline.
  3. Test simultaneous disturbances. Apply a push and a body change together, and a push shortly after a body change. A rule that only asks “is error still elevated?” has no way to say that both happened. This is where a richer signal, such as the direction of the residual or a short model-refit test, may become necessary.
  4. Move to a compliant body. Repeat on a compliant joint, first in simulation and then on hardware, where load-dependent deformation blurs the line between a body that changed and a body that is momentarily being acted on.

6Reproducibility

# check the push-capable step reproduces stock Pendulum-v1 exactly
python env_setup.py

# train (or load) the forward model, run the three conditions, write CSVs, figure and features
python run_experiment.py

# redraw Figure 1 from the saved CSVs
python plot.py

All scripts are in surprise_attribution/ of the self-model-research repository and depend only on numpy, torch, gymnasium and matplotlib. Every setting used here (onset, body-change factor, push torque and duration, feature windows, threshold) is defined in config.py. The trained model and the per-step error series for each condition are committed, so Figure 1 and Table 1 can be regenerated exactly.

References

Self Model Research
  1. Rung 1The Planner Hides the Model
  2. Rung 2A Wrong Model Is Worse Than None
  3. Rung 3Surprise Has a Signature (this report)
  4. Rung 4The Margin Was Rigid
  5. Rung 5An Arc of Elimination
  6. Rung 6The Quiet Body
  7. Rung 7Why Prediction Error Falls When the Body Changes