TensorBoardLogger#
- class braintools.trainer.TensorBoardLogger(save_dir, name='default', version=None, log_graph=False, default_hp_metric=True, prefix='', **kwargs)#
TensorBoard logging backend.
- Parameters:
save_dir (
str) – Directory to save TensorBoard logs.name (
str) – Experiment name (subdirectory).version (
str|None) – Version string. If None, auto-generates based on timestamp.log_graph (
bool) – Whether to log the model graph.default_hp_metric (
bool) – Whether to log hyperparameters with a default metric.prefix (
str) – Prefix for all metric names.
Examples
Construction is lazy; the writer is created on the first logging call:
>>> import os >>> import braintools >>> logger = braintools.trainer.TensorBoardLogger( ... 'logs', name='my_experiment', version='v0') >>> logger.log_dir == os.path.join('logs', 'my_experiment', 'v0') True >>> # Needs ``tensorboard`` (or ``tensorboardX``) installed and writes >>> # event files for a TensorBoard server, so it is not run here. >>> logger.log_metrics({'loss': 0.5}, step=0) >>> trainer = braintools.trainer.Trainer(logger=logger)
- finalize(status='success')[source]#
Finalize logging (called at end of training).
- Parameters:
status (
str) – Final status (‘success’, ‘failed’, ‘interrupted’).