Implementation:Danijar Dreamerv3 Logger And Report
| Knowledge Sources | |
|---|---|
| Domains | Reinforcement_Learning, Monitoring |
| Last Updated | 2026-02-15 09:00 GMT |
Overview
Concrete tool for multi-backend metric logging and open-loop video prediction reporting provided by the DreamerV3 agent and elements library.
Description
The logging system consists of:
- make_logger() in dreamerv3/main.py — Factory that creates an elements.Logger with configured output backends (terminal, JSONL, TensorBoard, WandB, Expa, Scope)
- Agent.report() in dreamerv3/agent.py — Generates open-loop predictions by observing the first half of sequences through the RSSM, then imagining the second half and decoding to pixel space
The logger uses elements.Agg for metric aggregation with configurable reduction (sum, avg, max, stack) and elements.FPS for throughput tracking.
Usage
make_logger is called once during initialization. Agent.report() is called periodically during training to generate diagnostic videos. Metric logging happens at log_every intervals; reporting at report_every intervals.
Code Reference
Source Location
- Repository: dreamerv3
- File: dreamerv3/main.py (make_logger), dreamerv3/agent.py (Agent.report)
- Lines: dreamerv3/main.py L152-180, dreamerv3/agent.py L247-310
Signature
def make_logger(config):
"""
Create a Logger with configured output backends.
Args:
config: elements.Config with config.logger.outputs (list of backend names),
config.logger.filter (terminal filter), config.logger.fps (video FPS).
Returns:
elements.Logger: Logger with step counter and output backends.
"""
def Agent.report(self, carry, data):
"""
Generate open-loop prediction report.
Args:
carry: Tuple of (enc_carry, dyn_carry, dec_carry, prevact).
data: Dict of batched sequences from replay buffer.
Returns:
carry: Updated carry state.
metrics: Dict containing 'openloop/{key}' video grids (uint8 arrays).
"""
Import
from dreamerv3.main import make_logger
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| config | elements.Config | Yes | Logger configuration with outputs list, filter, fps settings |
| carry | tuple | Yes | Agent carry state for report generation |
| data | dict | Yes | Batched sequences from replay for open-loop evaluation |
Outputs
| Name | Type | Description |
|---|---|---|
| logger | elements.Logger | Logger instance with add(metrics, prefix), write(), close() methods |
| metrics | dict | Report metrics including 'openloop/{key}' video grids as uint8 arrays of shape (T, H, B*W, C) |
Usage Examples
Logger Setup
from dreamerv3.main import make_logger
logger = make_logger(config)
# Add metrics and write
logger.add({'loss/dyn': 0.5, 'loss/rep': 0.3}, prefix='train')
logger.add({'score': 42.0, 'length': 1000}, prefix='episode')
logger.write()
# Close when done
logger.close()
Open-Loop Reporting
# During training loop
if should_report(step):
agg = elements.Agg()
for _ in range(args.report_batches):
carry_report, mets = agent.report(carry_report, next(stream_report))
agg.add(mets)
logger.add(agg.result(), prefix='report')