class_docstr: SSL Specific variant of the Classy Vision tensorboard hook
class_docstr_tok: ["SSL","Specific","variant","of","the","Classy","Vision","tensorboard","hook"]
docstr: The constructor method of SSLTensorboardHook.
  
  Args:
      tb_writer: `Tensorboard SummaryWriter <https://tensorboardx.
                  readthedocs.io/en/latest/tensorboard.html#tensorboardX.
                  SummaryWriter>`_ instance
      log_params (bool): whether to log model params to tensorboard
      log_params_every_n_iterations (int): frequency at which parameters
                  should be logged to tensorboard
      log_params_gradients (bool): whether to log params gradients as well
                  to tensorboard.
docstr_tok: ["The","constructor","method","of","SSLTensorboardHook",".","Args",":","tb_writer",":","`","Tensorboard","SummaryWriter","<","https",":","\/\/tensorboardx",".","readthedocs.io\/en\/latest\/tensorboard.html","#","tensorboardX",".","SummaryWriter",">","`","_","instance","log_params","(","bool",")",":","whether","to","log","model","params","to","tensorboard","log_params_every_n_iterations","(","int",")",":","frequency","at","which","parameters","should","be","logged","to","tensorboard","log_params_gradients","(","bool",")",":","whether","to","log","params","gradients","as","well","to","tensorboard","."]
code: def __init__(
      self,
      tb_writer: SummaryWriter,
      log_params: bool = False,
      log_params_every_n_iterations: int = -1,
      log_params_gradients: bool = False,
      log_activation_statistics: int = 0,
  ) -> None:
      """The constructor method of SSLTensorboardHook.
  
      Args:
          tb_writer: `Tensorboard SummaryWriter <https://tensorboardx.
                      readthedocs.io/en/latest/tensorboard.html#tensorboardX.
                      SummaryWriter>`_ instance
          log_params (bool): whether to log model params to tensorboard
          log_params_every_n_iterations (int): frequency at which parameters
                      should be logged to tensorboard
          log_params_gradients (bool): whether to log params gradients as well
                      to tensorboard.
      """
      super().__init__()
      if not tb_available:
          raise RuntimeError(
              "tensorboard not installed, cannot use SSLTensorboardHook"
          )
      logging.info("Setting up SSL Tensorboard Hook...")
      self.tb_writer = tb_writer
      self.log_params = log_params
      self.log_params_every_n_iterations = log_params_every_n_iterations
      self.log_params_gradients = log_params_gradients
      self.log_activation_statistics = log_activation_statistics
      if self.log_activation_statistics > 0:
          self.activation_watcher = ActivationStatisticsMonitor(
              observer=ActivationStatisticsTensorboardWatcher(
                  tb_writer
              ),
              log_frequency=self.log_activation_statistics,
              sample_feature_map=True,
          )
      logging.info(
          f"Tensorboard config: log_params: {self.log_params}, "
          f"log_params_freq: {self.log_params_every_n_iterations}, "
          f"log_params_gradients: {self.log_params_gradients}, "
          f"log_activation_statistics: {self.log_activation_statistics}"
      )
  
file_path: vissl/vissl/hooks/tensorboard_hook.py
imports: import logging
  import torch
  from classy_vision import tasks
  from classy_vision.generic.distributed_util import is_primary
  from classy_vision.hooks.classy_hook import ClassyHook
  from vissl.utils.activation_statistics import ActivationStatistics, ActivationStatisticsMonitor, ActivationStatisticsObserver
label_desc: Use image node_id 1 to create a new SSLTensorboardHook object from inherited base classes: ClassyHook with example: obj = SSLTensorboardHook(tb_writer, log_params, log_params_every_n_iterations, log_params_gradients, log_activation_statistics)