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

Method checkpoint

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

Periodic 'latest', 5M-step milestone, and best-gate checkpoints. state_fn() builds the dict only when a save actually happens.

(self, frames, state_fn, gate=None)

Source from the content-addressed store, hash-verified

98 return None
99
100 def checkpoint(self, frames, state_fn, gate=None):
101 """Periodic 'latest', 5M-step milestone, and best-gate checkpoints.
102 state_fn() builds the dict only when a save actually happens."""
103 if not self.ckpt_dir or not self.ckpt_every:
104 return
105 if frames - self.ckpt_last >= self.ckpt_every:
106 _atomic_save(state_fn(), os.path.join(self.ckpt_dir, "latest.pt"))
107 self.ckpt_last = frames
108 if frames - self.ms_last >= 5_000_000:
109 _atomic_save(state_fn(), os.path.join(self.ckpt_dir, f"step_{frames // 1_000_000}M.pt"))
110 self.ms_last = frames
111 if gate is not None and gate > self.best:
112 self.best = gate
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."""

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