chainer.training.extensions.snapshot_writers.ThreadWriter

class chainer.training.extensions.snapshot_writers.ThreadWriter(savefun=<function save_npz>, **kwds)[source]

Snapshot writer that uses a separate thread.

This class creates a new thread that invokes the actual saving function.

Methods

__call__(filename, outdir, target)[source]

Invokes the actual snapshot function.

This method is invoked by a Snapshot object every time it takes a snapshot.

Parameters
  • filename (str) – Name of the file into which the serialized target is saved. It is a concrete file name, i.e. not a pre-formatted template string.

  • outdir (str) – Output directory. Corresponds to Trainer.out.

  • target (dict) – Serialized object which will be saved.

create_worker(filename, outdir, target, **kwds)[source]

Creates a worker for the snapshot.

This method creates a thread or a process to take a snapshot. The created worker must have start() and join() methods.

Parameters
  • filename (str) – Name of the file into which the serialized target is saved. It is already formated string.

  • outdir (str) – Output directory. Passed by trainer.out.

  • target (dict) – Serialized object which will be saved.

  • kwds – Keyword arguments for the savefun.

finalize()[source]

Finalizes the wirter.

Like extensions in Trainer, this method is invoked at the end of the training.

save(filename, outdir, target, savefun, **kwds)[source]
__eq__(value, /)

Return self==value.

__ne__(value, /)

Return self!=value.

__lt__(value, /)

Return self<value.

__le__(value, /)

Return self<=value.

__gt__(value, /)

Return self>value.

__ge__(value, /)

Return self>=value.