chainer.training.extensions.snapshot_object¶
-
chainer.training.extensions.
snapshot_object
(target, filename, savefun=<function save_npz>, **kwargs)[source]¶ Returns a trainer extension to take snapshots of a given object.
This extension serializes the given object and saves it to the output directory.
This extension is called once per epoch by default. To take a snapshot at a different interval, a trigger object specifying the required interval can be passed along with this extension to the extend() method of the trainer.
The default priority is -100, which is lower than that of most built-in extensions.
- Parameters
target – Object to serialize.
filename (str) – Name of the file into which the object is serialized. It can be a format string, where the trainer object is passed to the
str.format()
method. For example,'snapshot_{.updater.iteration}'
is converted to'snapshot_10000'
at the 10,000th iteration.savefun – Function to save the object. It takes two arguments: the output file path and the object to serialize.
snapshot_on_error (bool) – Whether to take a snapshot in case trainer loop has been failed.
- Returns
Snapshot extension object.