Skip to content

DoubleCartpole-v0 ​

INFO

Esta página ainda não foi traduzida. Leia em inglês

Open in Colab

Underactuated double-pole stabilization.

mujoco · Environment reference.

A small LeWM baseline experiment: held-out dynamics prediction, a persistence control, and closed-loop planning against random actions. This validates the experiment pipeline; it is not a paper-scale training run.

python
import importlib.util

if importlib.util.find_spec("torch_world") is None:  # on Colab
    %pip install -q "torch-world[examples,benchmark]"
python
from pathlib import Path

from torch_world.benchmarks import observation_encoder, run_experiment, show_results
from torch_world.envs import DoubleCartpole
from torch_world.models import LeWM
from torch_world.planning import CEM

Protocol ​

2,048 requested training pairs; 400 updates; four evaluation seeds; 60-step evaluation budget. Puzzle training and holdout use disjoint starting states. Other tasks use separate collection seeds. Goal-renderable tasks use goal-image MPC; others learn a reward head on frozen embeddings and plan predicted rewards. Actual simulator returns are scored. The one-step model protocol uses history=1.

Rendering defaults to high quality: 128-pixel model inputs and 512-pixel presentation frames. Use quality="low" or quality="medium" to compare cost and quality; size and render_size can be set independently.

Fixed puzzle layouts use the same start for all four planner seeds. Success intervals therefore describe policy randomness on that level, not generalization across levels.

python
world = DoubleCartpole(quality="high")
SEED, UPDATES = 7, 400
OUTPUT_DIR = Path('../runs/benchmarks/20261015_high_quality')

# Replace this factory to compare another WorldModel with the same experiment.
def model_factory(observation_shape, action_dim):
    return LeWM(
        observation_encoder(observation_shape), action_dim, embed_dim=32, history=1,
        depth=2, num_heads=4, head_dim=8, mlp_dim=64, proj_dim=64, dropout=0,
    )


def planner_factory(action_dim):
    return CEM(8, action_dim, num_samples=96, num_elites=12, iterations=3, bounds=(-1, 1))
python
world.show_env()

DoubleCartpole-v0 · mujoco — Underactuated double-pole stabilization. 1 normalized action components in [-1, 1].

python
result = run_experiment(
    world, model_factory=model_factory, planner_factory=planner_factory,
    seed=SEED, updates=UPDATES, output_dir=OUTPUT_DIR,
)

Reference pending ​

A verified default success controller is not yet available for this task. Supply your controller with world.show_success(policy=your_controller) to display an episode GIF with GT. Failed rollouts are rejected. The measured model results below remain available.

Results ​

Lower prediction error alone does not establish planning competence.

python
show_results(result)
print("Saved run:", result["run_dir"])

DoubleCartpole-v0 · LeWM — pixels observations, seed 7, 400 updates, 2,048 training / 512 held-out pairs. cuda; 53.7 s.

Prediction methodHeld-out latent MSE ↓
LeWM336701.2188
Persistence0.1270

Latent standard deviation: 0.952. Latent errors are comparable within this model; their scale differs between models.

PolicySuccessStepsFinal distance ↓
LeWM + CEM0% [0%, 49%]60.011.260
random0% [0%, 49%]60.011.331

First evaluation seed shown; both policies start from the same state. All seeds are scored above.

Static preview of the recorded episode. Rerun this cell to view the animation.

text
Saved run: runs/benchmarks/20261015_high_quality/DoubleCartpole-v0/LeWM/20261015T114320627068Z-399770fa
python
world.close()