allennlp.training.tensorboard_writer

class allennlp.training.tensorboard_writer.TensorboardWriter(get_batch_num_total: Callable[int], serialization_dir: Optional[str] = None, summary_interval: int = 100, histogram_interval: int = None, should_log_parameter_statistics: bool = True, should_log_learning_rate: bool = False)[source]

Bases: object

Class that handles Tensorboard (and other) logging.

Parameters:
get_batch_num_total : Callable[[], int]

A thunk that returns the number of batches so far. Most likely this will be a closure around an instance variable in your Trainer class.

serialization_dir : str, optional (default = None)

If provided, this is where the Tensorboard logs will be written.

summary_interval : int, optional (default = 100)

Most statistics will be written out only every this many batches.

histogram_interval : int, optional (default = None)

If provided, activation histograms will be written out every this many batches. If None, activation histograms will not be written out.

should_log_parameter_statistics : bool, optional (default = True)

Whether to log parameter statistics.

should_log_learning_rate : bool, optional (default = False)

Whether to log learning rate.

add_train_histogram(name: str, values: torch.Tensor) → None[source]
add_train_scalar(name: str, value: float, timestep: int = None) → None[source]
add_validation_scalar(name: str, value: float, timestep: int = None) → None[source]
enable_activation_logging(model: allennlp.models.model.Model) → None[source]
log_activation_histogram(outputs, log_prefix: str) → None[source]
log_histograms(model: allennlp.models.model.Model, histogram_parameters: Set[str]) → None[source]

Send histograms of parameters to tensorboard.

log_learning_rates(model: allennlp.models.model.Model, optimizer: torch.optim.optimizer.Optimizer)[source]

Send current parameter specific learning rates to tensorboard

log_metrics(train_metrics: dict, val_metrics: dict = None, epoch: int = None, log_to_console: bool = False) → None[source]

Sends all of the train metrics (and validation metrics, if provided) to tensorboard.

log_parameter_and_gradient_statistics(model: allennlp.models.model.Model, batch_grad_norm: float) → None[source]

Send the mean and std of all parameters and gradients to tensorboard, as well as logging the average gradient norm.

should_log_histograms_this_batch() → bool[source]
should_log_this_batch() → bool[source]