close the RECAP critic-policy loop
This commit is contained in:
@@ -71,6 +71,8 @@ def test_experience_dataset_contract_and_intervention_label(tmp_path: Path) -> N
|
||||
assert intervention["returns"].shape == (16,)
|
||||
assert intervention["return_target"].shape == ()
|
||||
assert intervention["value_target"].shape == ()
|
||||
assert intervention["value_histories"].shape == (17, 8, 2)
|
||||
assert intervention["value_targets"].shape == (17,)
|
||||
assert intervention["advantages"].shape == (16,)
|
||||
assert intervention["advantage_label"] == "positive"
|
||||
assert intervention["reasoning"] == "Steer left."
|
||||
@@ -78,3 +80,21 @@ def test_experience_dataset_contract_and_intervention_label(tmp_path: Path) -> N
|
||||
intervention["actions"], intervention["history_xy"]
|
||||
)
|
||||
torch.testing.assert_close(decoded, intervention["future_xy"], atol=1e-5, rtol=1e-5)
|
||||
|
||||
|
||||
def test_learned_value_predictions_drive_advantage_relabeling(tmp_path: Path) -> None:
|
||||
manifest = _make_source_project(tmp_path / "source")
|
||||
dataset = Pi06ExperienceDataset(manifest, image_size=32)
|
||||
before = dataset.advantages.clone()
|
||||
predicted = torch.zeros(len(dataset.episodes), dataset.action_horizon + 1)
|
||||
predicted[:, :-1] = torch.linspace(-0.9, -0.1, dataset.action_horizon)
|
||||
|
||||
dataset.relabel_from_value_predictions(predicted)
|
||||
|
||||
assert not torch.allclose(dataset.advantages, before)
|
||||
intervention_index = next(
|
||||
index
|
||||
for index, episode in enumerate(dataset.episodes)
|
||||
if episode.source_type == "intervention_correction"
|
||||
)
|
||||
assert bool(dataset.positive_episodes[intervention_index])
|
||||
|
||||
Reference in New Issue
Block a user