SandHouse
Pages and contents

CL1 — Z

The Z Space

Encoding

Given an environment state Xt, we encode it into dense features using some efficient attention or vision architecture, likely FMA or a variant thereof.

Zt=Eθ(Xt)

where Eθ is the perceptual encoder. For an image or video frame, Zt may be represented as a collection of dense latent vectors

Zt=[zt,1,zt,2,...,zt,N]∈ℝN×d

These vectors do not initially have any required semantic interpretation. In particular, we do not require zt,i=objecti. A feature may instead represent some local visual pattern, region, texture, motion cue, object part, complete object, or more abstract property learned by the model. The purpose of Zis therefore to provide a rich perceptual representation that is

1. Useful for predicting future states (to the extent that sensory features at time t+1 depend on features at time t),
2. Accessible to the gamma space Γ and the reasoning head C,
3. Useful for impulsive action selection.

Explicit segmentation mechanisms are deferred, but are likely to improve unsupervised concept discovery in the Γ.

Predictive Prior

Although Zt is obtained directly from perception, the agent should also learn to predict how its latent perceptual state will evolve. The assumption introduced by this loss term is that a useful encoding of perception preserves information necessary to understand temporal dynamics. Given the current latent state and action,

Zt+1 | t−=DZ(Zt,At,Ht)

where DZ is the latent dynamics model. Zt+1∣t− represents the agent's prediction of the next latent state before observing Xt+1. This can be recursively propagated to predict multiple steps into the future:

Zt+k|t−=DZ(Zt+k−1|t−,At+k−1,Ht)

Thus Zt represents what is currently perceived while Zt+k|t− represents what the agent expects to perceive in the future.

World Model Prediction Loss

We want Zt to contain information that makes the future predictable. After observing the future environment

Zt+k=Eθ(Xt+k)

we compare the predicted latent state against the posterior representation produced from the actual observation. A simple JEPA-like objective is

ℒpred=∑k=1Kwk1N∑i=1N‖zt+k|t,i−−sg(zt+k,i)‖22

Here ‖zt+k|t,i−−sg(zt+k,i)‖22 measures the prediction error between the predicted future representation and the representation produced after actually observing the future. The stop-gradient sg(⋅) prevents the prediction target from simply moving toward the prediction. The outer sum ∑k=1Kwk(⋅) allows the model to learn predictions across multiple future horizons.

For the initial model, Zt can preserve the spatial organization produced by the encoder so that DZ predicts a future dense feature representation of the same general structure. If direct feature-to-feature prediction proves too restrictive because features move spatially through time, more sophisticated prediction, alignment, or grouping mechanisms can be introduced later.

This prediction loss term should propagate

ℒpred→DZ→Bt→UB

World Model Regularization

To prevent representation collapse, we must include a loss term that regularizes the latent distribution. The VISReg loss is one that handles center, scale, and full projected distributional shape, beating performance of SIGReg and with greater flexibility.

ℒreg=λscaleD∑j=1D(1−σj(Z^ℬ))2+λshapeK∑k=1K‖sort(Z^ℬwksg(σ)+ϵ)−q𝒩‖22+λcenter∥μ∥22

Where Z^ℬ represents the centered embedding of a replay buffer

Zℬ={Eθ,T(X1),Eθ,T(X2),...,Eθ,T(XT)},Z^ℬ=Zℬ−μℬ

sort(⋅) sorts the projected values in each dimension, and q𝒩∈ℝNrepresents the fixed quantiles of the standard Gaussian distribution. This has linear time complexity. The VISReg paper mentions that the default λ∗=1 works well for high-quality datasets, but increasing the shape loss weight improves performance on low-quality datasets.

Finally, we have the world model loss

ℒworld=ℒpred+λregℒreg

Reward Prediction

In addition to predicting future latent states, the world model should predict the reward associated with a transition. We introduce a small reward head RZ

r^t+1=RZ(Zt,At,Zt+1−)

where

Zt+1−=DZ(Zt,At,Ht)

The reward head can initially be a small MLP trained with

ℒreward=‖r^t+1−rt+1‖22

The complete world-model objective becomes

ℒworld=ℒpred+λregℒreg+λrℒreward

Keeping reward prediction separate from Z allows Z to remain a general perceptual/dynamical representation while RZ learns which predicted transitions are behaviorally valuable. During planning, candidate action sequences can be rolled through DZ and scored using RZ .

Role of Z

The initial purpose of Z is intentionally broad. We want

Xt→EθZt

to produce a representation from which both prediction and behavior can emerge. The two primary consumers of Zt are therefore Zt→DZ for world-model prediction and Zt→Ct for thought and planning. The policy may also access Zt directly so that simple behaviors do not necessarily have to pass through the entire thought process.