Training a real model can take hours or days — a crash, a preemption, or simply wanting to pause and resume later all mean the same thing: the current state of training (every parameter's current value, plus which epoch training had reached) needs to survive being written to disk and read back later, exactly.
Implement save_checkpoint(params, epoch, path) and load_checkpoint(path), a matched pair that write a model's parameters and its epoch number to a single file, and read them back exactly.
params: a dict mapping parameter names (strings) to NumPy arrays of any shape/dtype.path: expected to already end in .npz.save_checkpoint writes every named array plus the epoch integer to one file at path.load_checkpoint(path) returns (params, epoch): params has exactly the same name→array mapping that was saved, epoch is a plain Python int.load_checkpoint(path) immediately after save_checkpoint(params, epoch, path)) must reproduce params and epoch exactly.Open one at a time. Each gives away a little more than the last.
np.savez(path, **params) saves every dict entry as its own named array in one file — dict-unpacking with ** turns {"w": arr} into the keyword argument w=arr automatically.
Save the epoch under a key that could never collide with a real parameter name (like "__epoch__"), so load_checkpoint can tell "this one's the epoch" apart from "this one's a parameter" just by its key.
No results yet
Run your code to check it against the examples, or submit to run every test.