Add hdppo-InvertedPendulum-v5 package (weights, code, model card)
Browse filesFiles changed (3)
- README.md+1
- record_video.py+42-44
- replay.mp4Added
107 unmodified lines108109110111112113107 unmodified lines|------|-------------|| `hdppo-InvertedPendulum-v5/weights.npz` | Published actor (+ critic if HD) and FPE encoder (D=64) || `hdppo-InvertedPendulum-v5/weights_D512_teacher.npz` | Teacher checkpoint (D=512) || `results.json` | Evaluation summary for the published checkpoint || `results_D512_teacher.json` | Evaluation summary for the teacher || `config.yml` | Training hyperparameters |107 unmodified lines108109110111112113114107 unmodified lines|------|-------------|| `hdppo-InvertedPendulum-v5/weights.npz` | Published actor (+ critic if HD) and FPE encoder (D=64) || `hdppo-InvertedPendulum-v5/weights_D512_teacher.npz` | Teacher checkpoint (D=512) || `replay.mp4` | Sample rollout video from the published min-D checkpoint || `results.json` | Evaluation summary for the published checkpoint || `results_D512_teacher.json` | Evaluation summary for the teacher || `config.yml` | Training hyperparameters |
1234567891011121314151617181920212223242526272829303132333435363738394041424344import argparseimport osimport gymnasium as gymimport imageio.v2 as imageiofrom enjoy import load_policy_from_checkpointdef record(weights_path, output_path, seed=42, max_steps=1000):encoder, actor, cfg = load_policy_from_checkpoint(weights_path, seed=seed)env_kwargs = dict(cfg.get("env_kwargs", {}))env_kwargs["render_mode"] = "rgb_array"env = gym.make("InvertedPendulum-v5", **env_kwargs)frames = []obs, _ = env.reset(seed=seed)for _ in range(max_steps):Hr, Hi = encoder.encode(obs)action = actor.greedy_action_np(Hr, Hi)obs, reward, term, trunc, _ = env.step(action)frames.append(env.render())if term or trunc:breakenv.close()os.makedirs(os.path.dirname(output_path) or ".", exist_ok=True)imageio.mimsave(output_path, frames, fps=30)return len(frames)def main():parser = argparse.ArgumentParser(description="Record InvertedPendulum-v5 replay video")parser.add_argument("--weights", default="hdppo-InvertedPendulum-v5/weights.npz")parser.add_argument("--output", default="replay.mp4")parser.add_argument("--seed", type=int, default=42)parser.add_argument("--max-steps", type=int, default=1000)args = parser.parse_args()n = record(args.weights, args.output, seed=args.seed, max_steps=args.max_steps)print(f"saved {n} frames to {args.output}")if __name__ == "__main__":main()123456789101112131415161718192021222324252627282930313233343536373839404142import argparseimport osimport gymnasium as gymimport imageio.v2 as imageiofrom enjoy import load_policy_from_checkpointdef record(weights_path, output_path, seed=42, max_steps=1000):encoder, actor, cfg = load_policy_from_checkpoint(weights_path, seed=seed)env_kwargs = dict(cfg.get("env_kwargs", {}))env_kwargs["render_mode"] = "rgb_array"env = gym.make("InvertedPendulum-v5", **env_kwargs)frames = []obs, _ = env.reset(seed=seed)for _ in range(max_steps):Hr, Hi = encoder.encode(obs)action = actor.greedy_action_np(Hr, Hi)obs, reward, term, trunc, _ = env.step(action)frames.append(env.render())if term or trunc:breakenv.close()os.makedirs(os.path.dirname(output_path) or ".", exist_ok=True)imageio.mimsave(output_path, frames, fps=30)return len(frames)def main():parser = argparse.ArgumentParser(description="Record InvertedPendulum-v5 replay video")parser.add_argument("--weights", default="hdppo-InvertedPendulum-v5/weights.npz")parser.add_argument("--output", default="replay.mp4")parser.add_argument("--seed", type=int, default=42)parser.add_argument("--max-steps", type=int, default=1000)args = parser.parse_args()n = record(args.weights, args.output, seed=args.seed, max_steps=args.max_steps)print(f"saved {n} frames to {args.output}")if __name__ == "__main__":main()
README.md+1
record_video.py+42-44
replay.mp4Added