Metrics
Track time-series metrics that change over time - loss, accuracy, learning rate, and custom measurements.
Basic Usage
Log train and eval metrics together with a single call:
Alternative: Prefix-Based Logging
You can also log metrics using namespace prefixes with explicit context:
Include epoch (or step) in each group's log() call. A bare
exp.metrics.log(epoch=epoch) writes to a separate unnamed series; it is not
attached to the train and eval rows. The grouped form above,
exp.metrics.log(epoch=..., train=dict(...), eval=dict(...)), does copy
epoch into every group.
Custom Metric Groups
Define your own metric groups beyond train/eval:
Reading Data
Read metric data by index range:
Buffer API
For high-frequency logging (e.g., per-batch), use the buffer API to accumulate values and periodically log summary statistics:
This produces statistics like loss.mean, accuracy.mean per epoch.
Buffer API Methods
metrics("prefix").buffer(**kwargs)- Accumulate values for later summarizationmetrics.buffer.log_summary(*aggs)- Compute statistics and log to all prefixesmetrics.buffer.peek(prefix, *keys, limit=5)- Non-destructive look at buffered values
Supported Aggregations
Available aggregations: mean, std, min, max, count, median, sum, p50, p90, p95, p99, first, last
Multiple Prefixes
Buffer works across multiple prefixes simultaneously:
Summary Cache (Legacy API)
The summary cache API is still supported for backward compatibility:
Summary Cache Methods
store(**kwargs)- Accumulate values for later summarizationset(**kwargs)- Set metadata (epoch, lr) that doesn't need aggregationsummarize(clear=True)- Compute statistics and append to metricspeek(*keys, limit=5)- Non-destructive look at stored values
Rolling vs Cumulative
Training Loop Example
Multiple Metrics in One Call
Combine related metrics:
Timestamps
Every metric data point automatically records a _ts field (Unix timestamp, seconds since epoch). You can also provide it explicitly or inherit it from the previous call:
_ts=-1 inherits across both metrics and tracks within the same thread.
Storage Format
Local mode - JSONL files:
Remote mode - Two-tier storage:
- Hot tier: Recent data in MongoDB (fast access)
- Cold tier: Historical data in S3 (auto-archived after 10,000 points)
Next: Learn about Files to upload models, plots, and artifacts.