netket.logging.TBLog

class netket.logging.TBLog(*args, **kwargs)[source]

Bases: object

Creates a tensorboard logger using tensorboardX’s summarywriter. Refer to its documentation for further details

https://tensorboardx.readthedocs.io/en/latest/tensorboard.html

TensorBoardX must be installed.

Parameters
  • logdir (string) – Save directory location. Default is runs/CURRENT_DATETIME_HOSTNAME, which changes after each run. Use hierarchical folder structure to compare between runs easily. e.g. pass in ‘runs/exp1’, ‘runs/exp2’, etc. for each new experiment to compare across them.

  • comment (string) – Comment logdir suffix appended to the default logdir. If logdir is assigned, this argument has no effect.

  • purge_step (int) – When logging crashes at step \(T+X\) and restarts at step \(T\), any events whose global_step larger or equal to \(T\) will be purged and hidden from TensorBoard. Note that crashed and resumed experiments should have the same logdir.

  • max_queue (int) – Size of the queue for pending events and summaries before one of the ‘add’ calls forces a flush to disk. Default is ten items.

  • flush_secs (int) – How often, in seconds, to flush the pending events and summaries to disk. Default is every two minutes.

  • filename_suffix (string) – Suffix added to all event filenames in the logdir directory. More details on filename construction in tensorboard.summary.writer.event_file_writer.EventFileWriter.

  • write_to_disk (boolean) – If pass False, TBLog will not write to disk.

Examples

Logging optimisation to tensorboard.

>>> import netket as nk
>>> # create a summary writer with automatically generated folder name.
>>> writer = nk.logging.TBLog()
>>> # folder location: runs/May04_22-14-54_s-MacBook-Pro.local/
>>> # create a summary writer using the specified folder name.
>>> writer = nk.logging.TBLog("my_experiment")
>>> # folder location: my_experiment
>>> # create a summary writer with comment appended.
>>> writer = nk.logging.TBLog(comment="LR_0.1_BATCH_16")
>>> # folder location: runs/May04_22-14-54_s-MacBook-Pro.localLR_0.1_BATCH_16/
__init__(*args, **kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods
__call__(step, item, machine)[source]

Call self as a function.

flush(machine=None)[source]

Writes to file the content of this logger.

Parameters

machine – optionally also writes the parameters of the machine.