TD-JEPA
Bagatella, Pirotta, Touati, Lazaric and Tirinzoni, TD-JEPA: Latent-predictive Representations for Zero-Shot Reinforcement Learning, ICLR 2026. Paper · Code: not released · Notebook
TD-JEPA learns, from reward-free transitions, a state encoder
Bars are target networks.
Usage
from torch_world.models import TDJEPA
from torch_world.models.jepa import drq_encoder
model = TDJEPA(drq_encoder(256), drq_encoder(50, hidden_layers=2), action_dim=2, discount=0.98)
opt = torch.optim.Adam(model.param_groups(1e-4))
out = model(pixels, actions) # transitions (B, 2, C, H, W), (B, 2, A); actions[:, 0] is taken at s
# out: {"loss", "td_phi_loss", "td_psi_loss", "ortho_loss", "actor_loss"}
model.update_target(0.995) # after each optimizer step
z_goal = model.goal_task(goal_images) # (B, task_dim), no training
z_reward = model.infer_task(frames, r) # (task_dim,) from rewards r (N,) at frames (N, C, H, W)
policy = model.controller(z_goal) # observation (B, C, H, W) -> action (B, A)
action = model.policy(model.encode(obs[:, None])[:, 0], z_goal)
q = model.value(z, action, z_goal) # T_phi(z, a, task) . taskTDJEPA subclasses JEPA, not WorldModel: its predictor forecasts discounted future embeddings under a policy, not the next latent, so there is nothing for CEM or MPPI to unroll. It acts with its own task-conditioned policy instead. forward returns the encoder, predictor and actor losses together. Their gradients reach disjoint parameters: the actor sees detached
The defaults follow the paper's DMC-from-pixels column (Table 4): drq_encoder, are DrQ-v2's convolutions with random shifts of up to 2 pixels, a linear head for
The notebook trains on Two-Rooms random-action pixels for 15k steps, with no rewards. It then reaches goal images in the other room 98% of the time (random actions: 3%) and solves three unseen rewards, each inferred by one linear regression, in 89% to 100% of episodes.
Choices the paper leaves open, and deviations:
- No released code. Network layouts follow Touati et al. (2023), which the paper cites for its architectures. Predictors embed
and each with Linear, LayerNorm and Tanh, then Linear and ReLU to half width, and twin ReLU heads share these embeddings. The actor embeds and the same way. Its noise is clipped at 0.3, as in Touati et al.'s code. - Normalization. The paper says encoder outputs are L2-normalized. Here they are projected to radius
, the scale of the task sphere, as in Touati et al.'s code. Inferred tasks are projected onto the same sphere. - Actor loss. The paper's pseudocode adds
to the loss, which contradicts Algorithm 1's . This implementation follows Algorithm 1. It also stops the actor loss from updating , as Algorithm 1's separate updates imply. - Twins. Each twin head is regressed onto the shared target and the losses are averaged over heads.
- Goals. The paper evaluates goal-reaching by regressing a goal reward.
goal_taskuses, or the whitened of its Appendix D.5 when reference observations are passed. On Two-Rooms, plain worked far better: in a tuning run at 20k steps it reached 98% of goals in the other room, against 41% for the version whitened on 1,024 dataset frames. - Not included: the FlowQ-style behavior-cloning regularizer the paper adds on OGBench's narrow datasets, frame stacking (Two-Rooms images are Markov), and the TD3 fine-tuning of Section 5.4.
- Scale. The paper trains for 1 to 2M steps. The notebook trains for far fewer.
Reference
Arguments and methods: TDJEPA in the API reference.
