Nadeem-Shoukath115113's picture
download
raw
1.9 kB
import sys, yaml, torch
from pathlib import Path
from torch.utils.data import DataLoader
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT))
cfg = yaml.safe_load(open(ROOT / "config/sarm2.yaml"))["cfg"]
m, g = cfg["model"], cfg["general"]
from lerobot.common.datasets.rm_act_pri_lerobot_dataset import FrameGapLeRobotDataset
from utils.data_utils import get_valid_episodes, split_train_eval_episodes, adapt_lerobot_batch_act_pri
eps = get_valid_episodes(g["repo_id"])
_, val_eps = split_train_eval_episodes(eps, train_ratio=1 - cfg["train"]["val_portion"], seed=g["seed"])
print("val episodes:", val_eps)
ds = FrameGapLeRobotDataset(
repo_id=g["repo_id"], image_names=g["camera_names"], episodes=val_eps,
n_obs_steps=m["n_obs_steps"], frame_gap=m["frame_gap"],
max_rewind_steps=m["max_rewind_steps"], task_list=m["task_list"], stage_model=False,
)
dl = DataLoader(ds, batch_size=64, shuffle=False, num_workers=6)
chunks = []
for i, b in enumerate(dl):
a = adapt_lerobot_batch_act_pri(b, n_obs_steps=m["n_obs_steps"], camera_names=g["camera_names"])
trg = a["steps_to_go"] if m["use_future_step"] else a["targets"]
chunks.append(trg.reshape(-1))
if i >= 24:
break
t = torch.cat(chunks).double()
mu = t.mean()
print("\ntarget = steps_to_go = 1 - progress (use_future_step=%s)" % m["use_future_step"])
print("n=%d min=%.3f max=%.3f mean=%.4f std=%.4f" % (t.numel(), t.min(), t.max(), mu, t.std()))
print("\nMSE of constant-0.5 predictor : %.5f" % ((t - 0.5) ** 2).mean())
print("MSE of constant-mean predictor: %.5f <-- baseline" % ((t - mu) ** 2).mean())
VAL = 0.049699808093341624
print("\nactual val/loss epoch1 : %.5f" % VAL)
print("R^2 vs constant-mean : %.3f" % (1 - VAL / ((t - mu) ** 2).mean().item()))
print("RMSE in progress units : %.3f (= %.1f%% of an episode)" % (VAL ** 0.5, 100 * VAL ** 0.5))

Xet Storage Details

Size:
1.9 kB
·
Xet hash:
f47ad55a4aa2a7e1a5d1c112f786010ec85f58d20446f9f10c2e612cda2136a5

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.