Add pooled features and targets (pooled/)
#3
by podolinsky - opened
- pooled/README.md +45 -0
- pooled/features.npz +3 -0
- pooled/pool_features.py +39 -0
- pooled/targets.npz +3 -0
pooled/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Pooled features and targets
|
| 2 |
+
|
| 3 |
+
Two files derived from the `rollout.npz` files and the labels of this dataset, for training probes on the policy's token embeddings
|
| 4 |
+
without loading the 114 MB rollouts. Both are keyed by the `dir` column of `manifest.csv` (for example `basket/ep000`), and step `t` of an
|
| 5 |
+
episode's targets lines up with row `t` of its features and with policy step `t` of `rollout.npz`.
|
| 6 |
+
|
| 7 |
+
## features.npz
|
| 8 |
+
|
| 9 |
+
One float32 array of shape (policy steps, 6144) per episode: 399 arrays, one row per policy step (`n_policy` in `manifest.csv`).
|
| 10 |
+
|
| 11 |
+
| columns | content |
|
| 12 |
+
|---|---|
|
| 13 |
+
| 0-2047 | mean over the 88 base-image tokens (`base_image` in `rollout.npz`) |
|
| 14 |
+
| 2048-4095 | mean over the 88 wrist-image tokens (`wrist_image`) |
|
| 15 |
+
| 4096-6143 | mean over the non-padded language tokens (`language`, the tokens where `language_mask` is true; 4 of 200 per step here) |
|
| 16 |
+
|
| 17 |
+
The tokens are stored as float16 in `rollout.npz` and averaged in float32. `pool_features.py` is the code that produced the file; run on
|
| 18 |
+
`basket/ep000` it reproduces the stored array exactly.
|
| 19 |
+
|
| 20 |
+
## targets.npz
|
| 21 |
+
|
| 22 |
+
Targets for the auxiliary heads of failure probes, built from the labels of this dataset (`labels.json`).
|
| 23 |
+
|
| 24 |
+
| key | shape, type | content |
|
| 25 |
+
|---|---|---|
|
| 26 |
+
| `phrases` | (896,) str | sorted unique phrases of the semantic timelines (`semantic_timeline` in `labels.json`) of all 399 episodes |
|
| 27 |
+
| `phrase_embeddings` | (896, 512) float32 | L2-normalised CLIP ViT-B/32 (`openai/clip-vit-base-patch32`) text features of the phrases |
|
| 28 |
+
| `mode_names` | (10,) str | the failure-mode classes: `wrong_object`, `stuck_or_no_progress`, `wrong_target`, `object_displacement`, `placement_or_insertion_failure`, `grasp_failure`, `open_close_failure`, `press_failure`, `other`, `timeout_or_insufficient_progress` |
|
| 29 |
+
| `phrase_ids/<dir>` | (policy steps,) int32 | for each policy step, the index into `phrases` of the timeline segment that covers it; -1 where there is none |
|
| 30 |
+
| `mode/<dir>` | scalar int8 | index into `mode_names` (`fail_mode` of `labels.npz`); present for the 254 failed episodes only |
|
| 31 |
+
|
| 32 |
+
How the phrase of a step is chosen: it is the phrase of the timeline segment whose policy-step range covers the step (a later segment overwrites a
|
| 33 |
+
step shared with the previous one); steps after a segment that no segment covers repeat the previous step's phrase; steps before the first segment
|
| 34 |
+
are -1. The failure modes are the labeller's output (see `LABELS.md`: Gemini, not individually verified), and only seven of the ten classes occur.
|
| 35 |
+
|
| 36 |
+
```python
|
| 37 |
+
import numpy as np
|
| 38 |
+
f, z = np.load("features.npz"), np.load("targets.npz")
|
| 39 |
+
x = f[dir] # (steps, 6144), dir such as "basket/ep000"
|
| 40 |
+
ids = z["phrase_ids/" + dir] # (steps,)
|
| 41 |
+
clip_target = z["phrase_embeddings"][ids] # (steps, 512); rows where ids < 0 have no target
|
| 42 |
+
mode = z["mode_names"][z["mode/" + dir]] if "mode/" + dir in z.files else None # failed episodes only
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
License: the same as the rest of this dataset.
|
pooled/features.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:401a47d01ca4833253857083b44266c470287f1ad4beb04e4b1060f08e083519
|
| 3 |
+
size 896097570
|
pooled/pool_features.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""How pooled/features.npz was made: one (policy steps, 6144) float32 array per episode, pooled from its rollout.npz.
|
| 2 |
+
|
| 3 |
+
python pool_features.py <dataset folder with manifest.csv and <dir>/rollout.npz> features.npz
|
| 4 |
+
|
| 5 |
+
Columns: [0:2048] mean over the base-image tokens, [2048:4096] mean over the wrist-image tokens,
|
| 6 |
+
[4096:6144] mean over the non-padded language tokens (language_mask), all averaged in float32.
|
| 7 |
+
"""
|
| 8 |
+
|
| 9 |
+
import csv
|
| 10 |
+
import sys
|
| 11 |
+
from pathlib import Path
|
| 12 |
+
|
| 13 |
+
import numpy as np
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def pool_rollout(path: Path) -> np.ndarray:
|
| 17 |
+
"""(n_policy, 6144) float32 from one rollout.npz."""
|
| 18 |
+
with np.load(path) as z:
|
| 19 |
+
base = z["base_image"].astype(np.float32).mean(axis=1) # (steps, 88, 2048) -> (steps, 2048)
|
| 20 |
+
wrist = z["wrist_image"].astype(np.float32).mean(axis=1)
|
| 21 |
+
mask = z["language_mask"].astype(np.float32) # (steps, 200), True for real tokens
|
| 22 |
+
language = (z["language"].astype(np.float32) * mask[..., None]).sum(axis=1) / np.maximum(mask.sum(axis=1, keepdims=True), 1.0)
|
| 23 |
+
return np.concatenate([base, wrist, language], axis=1).astype(np.float32)
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def main(root: str, out: str) -> None:
|
| 27 |
+
with open(Path(root) / "manifest.csv", newline="") as f:
|
| 28 |
+
rows = list(csv.DictReader(f))
|
| 29 |
+
arrays = {}
|
| 30 |
+
for r in rows:
|
| 31 |
+
x = pool_rollout(Path(root) / r["dir"] / "rollout.npz")
|
| 32 |
+
assert x.shape == (int(r["n_policy"]), 6144), (r["dir"], x.shape) # one row per policy step
|
| 33 |
+
arrays[r["dir"]] = x
|
| 34 |
+
np.savez(out, **arrays) # keys are the `dir` column of manifest.csv
|
| 35 |
+
print(f"wrote {len(arrays)} episodes to {out}")
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
if __name__ == "__main__":
|
| 39 |
+
main(sys.argv[1], sys.argv[2])
|
pooled/targets.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f48398f44df421ccddd288e2742112340b8ac7bb4532cb7117b5cf5deae81896
|
| 3 |
+
size 2332318
|