# danijar/daydreamer architecture

> Architecture diagram of the GitHub repository danijar/daydreamer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/danijar/daydreamer
- Repository: https://github.com/danijar/daydreamer

## Overview

This repository’s documented product is DayDreamer: a world-model reinforcement-learning system for physical robots. Its principal workflow has an acting process collecting robot/environment experience into replay, followed by a learner that trains a latent world model and an actor-critic behavior from replay and imagined trajectories. The tree also contains separate locomotion-imitation and model-free RL implementations; they are not folded into that documented workflow. Some runtime wiring is unsampled, so uncertain links are omitted.

Main entry points: [`embodied/run/acting.py`](https://github.com/danijar/daydreamer/blob/main/embodied/run/acting.py) (Acting process), [`embodied/agents/dreamerv2plus/train.py`](https://github.com/danijar/daydreamer/blob/main/embodied/agents/dreamerv2plus/train.py) (Train entry), [`embodied/run/learning.py`](https://github.com/danijar/daydreamer/blob/main/embodied/run/learning.py) (Learning process), [`embodied/agents/dreamerv2plus/agent.py`](https://github.com/danijar/daydreamer/blob/main/embodied/agents/dreamerv2plus/agent.py) (Dreamer agent)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_operation["Execution"]
  node_entry["Train entry<br/>[train.py]"]
  node_acting["Acting process<br/>[acting.py]"]
  node_learning["Learning process<br/>[learning.py]"]
  node_ppo["Imitation PPO<br/>[ppo_imitation.py]"]
  node_imitationrun["Imitation runner"]
end

subgraph group_world["World Model"]
  node_agent["Dreamer agent<br/>[agent.py]"]
  node_behavior["Actor-critic<br/>[behaviors.py]"]
  node_networks["Model networks<br/>[nets.py]"]
  node_tfutils["TensorFlow utilities<br/>[tfutils.py]"]
end

subgraph group_robot["Robot Environments"]
  node_environment["Environment adapters<br/>[robot_interface.py]"]
  node_gym["Gym adapter<br/>[gym.py]"]
  node_robot["Robot task environments"]
  node_builder["Robot environment builder<br/>[env_builder.py]"]
  node_motion["Reference motion task<br/>[imitation_task.py]"]
  node_motiondata["Motion data<br/>[motion_data.py]"]
end

subgraph group_memory["Experience"]
  node_replay[("Replay store<br/>[store.py]")]
  node_random["Random policy<br/>[random.py]"]
end

node_operator(("Operator"))

node_operator -->|"starts"| node_entry
node_entry -->|"runs acting"| node_acting
node_entry -->|"runs learning"| node_learning
node_acting -.->|"interacts with"| node_environment
node_acting -->|"stores experience"| node_replay
node_learning -->|"samples experience"| node_replay
node_learning -.->|"trains"| node_agent
node_agent -->|"updates behavior"| node_behavior
node_agent -->|"uses"| node_networks
node_networks -->|"uses"| node_tfutils
node_builder -->|"constructs"| node_robot
node_robot -.->|"wraps task"| node_motion
node_motion -->|"loads reference"| node_motiondata
node_imitationrun -->|"trains with"| node_ppo
node_imitationrun -.->|"builds environment"| node_builder
node_acting -.->|"fallback policy"| node_random

click node_entry "https://github.com/danijar/daydreamer/blob/main/embodied/agents/dreamerv2plus/train.py"
click node_acting "https://github.com/danijar/daydreamer/blob/main/embodied/run/acting.py"
click node_learning "https://github.com/danijar/daydreamer/blob/main/embodied/run/learning.py"
click node_agent "https://github.com/danijar/daydreamer/blob/main/embodied/agents/dreamerv2plus/agent.py"
click node_behavior "https://github.com/danijar/daydreamer/blob/main/embodied/agents/dreamerv2plus/behaviors.py"
click node_networks "https://github.com/danijar/daydreamer/blob/main/embodied/agents/dreamerv2plus/nets.py"
click node_tfutils "https://github.com/danijar/daydreamer/blob/main/embodied/agents/dreamerv2plus/tfutils.py"
click node_environment "https://github.com/danijar/daydreamer/blob/main/embodied/envs/robot_interface.py"
click node_gym "https://github.com/danijar/daydreamer/blob/main/embodied/envs/gym.py"
click node_robot "https://github.com/danijar/daydreamer/blob/main/motion_imitation/envs/locomotion_gym_env.py"
click node_builder "https://github.com/danijar/daydreamer/blob/main/motion_imitation/envs/env_builder.py"
click node_replay "https://github.com/danijar/daydreamer/blob/main/embodied/replay/store.py"
click node_random "https://github.com/danijar/daydreamer/blob/main/embodied/core/random.py"
click node_motion "https://github.com/danijar/daydreamer/blob/main/motion_imitation/envs/env_wrappers/imitation_task.py"
click node_motiondata "https://github.com/danijar/daydreamer/blob/main/motion_imitation/utilities/motion_data.py"
click node_ppo "https://github.com/danijar/daydreamer/blob/main/motion_imitation/learning/ppo_imitation.py"
click node_imitationrun "https://github.com/danijar/daydreamer/blob/main/motion_imitation/learning/imitation_runners.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry,node_acting,node_learning,node_ppo,node_imitationrun toneBlue
class node_agent,node_behavior,node_networks,node_tfutils toneAmber
class node_environment,node_gym,node_robot,node_builder,node_motion,node_motiondata toneMint
class node_replay,node_random toneRose
class node_operator toneIndigo
```

## Components

### Execution

- [Train entry](https://github.com/danijar/daydreamer/blob/main/embodied/agents/dreamerv2plus/train.py): `embodied/agents/dreamerv2plus/train.py`
- [Acting process](https://github.com/danijar/daydreamer/blob/main/embodied/run/acting.py): `embodied/run/acting.py`
- [Learning process](https://github.com/danijar/daydreamer/blob/main/embodied/run/learning.py): `embodied/run/learning.py`
- [Imitation PPO](https://github.com/danijar/daydreamer/blob/main/motion_imitation/learning/ppo_imitation.py): `motion_imitation/learning/ppo_imitation.py`
- [Imitation runner](https://github.com/danijar/daydreamer/blob/main/motion_imitation/learning/imitation_runners.py): `motion_imitation/learning/imitation_runners.py`

### World Model

- [Dreamer agent](https://github.com/danijar/daydreamer/blob/main/embodied/agents/dreamerv2plus/agent.py): `embodied/agents/dreamerv2plus/agent.py`
- [Actor-critic](https://github.com/danijar/daydreamer/blob/main/embodied/agents/dreamerv2plus/behaviors.py): `embodied/agents/dreamerv2plus/behaviors.py`
- [Model networks](https://github.com/danijar/daydreamer/blob/main/embodied/agents/dreamerv2plus/nets.py): `embodied/agents/dreamerv2plus/nets.py`
- [TensorFlow utilities](https://github.com/danijar/daydreamer/blob/main/embodied/agents/dreamerv2plus/tfutils.py): `embodied/agents/dreamerv2plus/tfutils.py`

### Robot Environments

- [Environment adapters](https://github.com/danijar/daydreamer/blob/main/embodied/envs/robot_interface.py): `embodied/envs/robot_interface.py`
- [Gym adapter](https://github.com/danijar/daydreamer/blob/main/embodied/envs/gym.py): `embodied/envs/gym.py`
- [Robot task environments](https://github.com/danijar/daydreamer/blob/main/motion_imitation/envs/locomotion_gym_env.py): `motion_imitation/envs/locomotion_gym_env.py`
- [Robot environment builder](https://github.com/danijar/daydreamer/blob/main/motion_imitation/envs/env_builder.py): `motion_imitation/envs/env_builder.py`
- [Reference motion task](https://github.com/danijar/daydreamer/blob/main/motion_imitation/envs/env_wrappers/imitation_task.py): `motion_imitation/envs/env_wrappers/imitation_task.py`
- [Motion data](https://github.com/danijar/daydreamer/blob/main/motion_imitation/utilities/motion_data.py): `motion_imitation/utilities/motion_data.py`

### Experience

- [Replay store](https://github.com/danijar/daydreamer/blob/main/embodied/replay/store.py): `embodied/replay/store.py`
- [Random policy](https://github.com/danijar/daydreamer/blob/main/embodied/core/random.py): `embodied/core/random.py`

### Other components

- **Operator**

## Connections

- Operator → Train entry: starts (evidence: `README.md`)
- Train entry → Acting process: runs acting (evidence: `README.md`)
- Train entry → Learning process: runs learning (evidence: `README.md`)
- Acting process → Environment adapters: interacts with
- Acting process → Replay store: stores experience (evidence: `README.md`)
- Learning process → Replay store: samples experience (evidence: `README.md`)
- Learning process → Dreamer agent: trains
- Dreamer agent → Actor-critic: updates behavior (evidence: `embodied/agents/dreamerv2plus/agent.py`)
- Dreamer agent → Model networks: uses (evidence: `embodied/agents/dreamerv2plus/agent.py`)
- Model networks → TensorFlow utilities: uses (evidence: `embodied/agents/dreamerv2plus/nets.py`)
- Robot environment builder → Robot task environments: constructs (evidence: `motion_imitation/envs/env_builder.py`)
- Robot task environments → Reference motion task: wraps task
- Reference motion task → Motion data: loads reference (evidence: `motion_imitation/envs/env_wrappers/imitation_task.py`)
- Imitation runner → Imitation PPO: trains with (evidence: `motion_imitation/learning/ppo_imitation.py`)
- Imitation runner → Robot environment builder: builds environment
- Acting process → Random policy: fallback policy
