MCPcopy Create free account
hub / github.com/rlcode/reinforcement-learning / finalize

Method finalize

4-atari-hard/env.py:115–128  ·  view source on GitHub ↗

Final 'latest' checkpoint + a final.json result summary.

(self, frames, game_returns, state_fn, k=100)

Source from the content-addressed store, hash-verified

113 _atomic_save(state_fn(), os.path.join(self.ckpt_dir, "best.pt"))
114
115 def finalize(self, frames, game_returns, state_fn, k=100):
116 """Final 'latest' checkpoint + a final.json result summary."""
117 if self.ckpt_dir:
118 _atomic_save(state_fn(), os.path.join(self.ckpt_dir, "latest.pt"))
119 if self.dir:
120 tail = [float(x) for x in game_returns[-k:]]
121 with open(os.path.join(self.dir, "final.json"), "w") as fh:
122 json.dump({"frames_total": frames, "frames_unit": "agent_steps",
123 "gate_metric": "game_return_mean_lastK", "K": k,
124 "value_mean": statistics.fmean(tail) if tail else float("nan"),
125 "value_std": statistics.pstdev(tail) if len(tail) > 1 else 0.0,
126 "episodes_counted": len(tail)}, fh, indent=1)
127 if self.f:
128 self.f.close()
129
130
131# Gymnasium / ALE id (used by make_env / --test rendering) paired with the

Callers 3

mainFunction · 0.95
1-ppo-rnd.pyFile · 0.45
2-go-explore.pyFile · 0.45

Calls 1

_atomic_saveFunction · 0.70

Tested by

no test coverage detected