tensorboard

class aitoolbox.torchtrain.callbacks.tensorboard.TensorboardReporterBaseCB(callback_name, log_dir=None, is_project=True, project_name=None, experiment_name=None, local_model_result_folder_path=None, cloud_save_mode=None, bucket_name=None, cloud_dir_prefix=None, **kwargs)[source]

Bases: AbstractExperimentCallback

Base Tensorboard callback wrapping SummaryWriter

This base callback is intended to be inherited and extended with the more concrete callback geared towards a particular use-case. This callback only setups all the folders needed for local and cloud experiment tracking.

Parameters:
  • callback_name (str) – name of the callback

  • log_dir (str or None) – save directory location

  • is_project (bool) – set to True if the results should be saved into the TrainLoop-created project folder structure or to False if you want to save into a specific full path given in the log_dir parameter.

  • project_name (str or None) – root name of the project

  • experiment_name (str or None) – name of the particular experiment

  • local_model_result_folder_path (str or None) – root local path where project folder will be created

  • cloud_save_mode (str or None) – Storage destination selector. For AWS S3: ‘s3’ / ‘aws_s3’ / ‘aws’ For Google Cloud Storage: ‘gcs’ / ‘google_storage’ / ‘google storage’ Everything else results just in local storage to disk

  • bucket_name (str) – name of the bucket in the cloud storage

  • cloud_dir_prefix (str) – path to the folder inside the bucket where the experiments are going to be saved

  • **kwargs – additional arguments for torch.utils.tensorboard.SummaryWriter wrapped inside this callback

log_mid_train_loss()[source]

Log the training loss at the batch iteration level

Logs current batch loss and the accumulated average loss.

Returns:

None

log_train_history_metrics(metric_names)[source]

Log the train history metrics at the end of the epoch

Parameters:

metric_names (list) – list of train history tracked metrics to be logged

Returns:

None

on_train_end()[source]

Logic executed at the end of the overall training

Returns:

None

on_train_loop_registration()[source]

Execute callback initialization / preparation after the train_loop_object becomes available

Returns:

None

create_log_dir()[source]
prepare_results_saver()[source]
upload_to_cloud()[source]

Upload sync the local version of tensorboard file to the cloud storage

Will only upload to cloud if this callback is used as part of the experiment tracking TrainLoop and the results are saved in the cloud experiment’s folder.

Returns:

None

class aitoolbox.torchtrain.callbacks.tensorboard.TensorboardTrainBatchLoss(batch_log_frequency=1, log_dir=None, is_project=True, project_name=None, experiment_name=None, local_model_result_folder_path=None, cloud_save_mode=None, bucket_name=None, cloud_dir_prefix=None, **kwargs)[source]

Bases: TensorboardReporterBaseCB

Tensorboard training loss logger

Parameters:
  • batch_log_frequency (int) – frequency of logging

  • log_dir (str or None) – save directory location

  • is_project (bool) – set to True if the results should be saved into the TrainLoop-created project folder structure or to False if you want to save into a specific full path given in the log_dir parameter.

  • project_name (str or None) – root name of the project

  • experiment_name (str or None) – name of the particular experiment

  • local_model_result_folder_path (str or None) – root local path where project folder will be created

  • cloud_save_mode (str or None) – Storage destination selector. For AWS S3: ‘s3’ / ‘aws_s3’ / ‘aws’ For Google Cloud Storage: ‘gcs’ / ‘google_storage’ / ‘google storage’ Everything else results just in local storage to disk

  • bucket_name (str) – name of the bucket in the cloud storage

  • cloud_dir_prefix (str) – path to the folder inside the bucket where the experiments are going to be saved

  • **kwargs – additional arguments for torch.utils.tensorboard.SummaryWriter wrapped inside this callback

on_batch_end()[source]

Logic executed after the batch is inserted into the model

Returns:

None

on_epoch_end()[source]

Logic executed at the end of the epoch

Returns:

None

class aitoolbox.torchtrain.callbacks.tensorboard.TensorboardTrainHistoryMetric(metric_names=None, log_dir=None, is_project=True, project_name=None, experiment_name=None, local_model_result_folder_path=None, cloud_save_mode=None, bucket_name=None, cloud_dir_prefix=None, **kwargs)[source]

Bases: TensorboardReporterBaseCB

Tensorboard training history values logger

At each end of epoch logs to tensorboard the last value in the training history stored for some tracked metric.

Parameters:
  • metric_names (list or None) – list of metric names tracked in the training history. If left to None, all the metrics in the training history will be logged.

  • log_dir (str or None) – save directory location

  • is_project (bool) – set to True if the results should be saved into the TrainLoop-created project folder structure or to False if you want to save into a specific full path given in the log_dir parameter.

  • project_name (str or None) – root name of the project

  • experiment_name (str or None) – name of the particular experiment

  • local_model_result_folder_path (str or None) – root local path where project folder will be created

  • cloud_save_mode (str or None) – Storage destination selector. For AWS S3: ‘s3’ / ‘aws_s3’ / ‘aws’ For Google Cloud Storage: ‘gcs’ / ‘google_storage’ / ‘google storage’ Everything else results just in local storage to disk

  • bucket_name (str) – name of the bucket in the cloud storage

  • cloud_dir_prefix (str) – path to the folder inside the bucket where the experiments are going to be saved

  • **kwargs – additional arguments for torch.utils.tensorboard.SummaryWriter wrapped inside this callback

on_epoch_end()[source]

Logic executed at the end of the epoch

Returns:

None

class aitoolbox.torchtrain.callbacks.tensorboard.TensorboardFullTracking(metric_names=None, batch_log_frequency=1, log_dir=None, is_project=True, project_name=None, experiment_name=None, local_model_result_folder_path=None, cloud_save_mode=None, bucket_name=None, cloud_dir_prefix=None, **kwargs)[source]

Bases: TensorboardReporterBaseCB

Full Tensorboard logger

At each end of epoch logs to tensorboard the last value in the training history stored for some tracked metric. Also logs the training loss at the batch iteration level.

Parameters:
  • metric_names (list or None) – list of metric names tracked in the training history. If left to None, all the metrics in the training history will be logged.

  • batch_log_frequency (int) – frequency of logging

  • log_dir (str or None) – save directory location

  • is_project (bool) – set to True if the results should be saved into the TrainLoop-created project folder structure or to False if you want to save into a specific full path given in the log_dir parameter.

  • project_name (str or None) – root name of the project

  • experiment_name (str or None) – name of the particular experiment

  • local_model_result_folder_path (str or None) – root local path where project folder will be created

  • cloud_save_mode (str or None) – Storage destination selector. For AWS S3: ‘s3’ / ‘aws_s3’ / ‘aws’ For Google Cloud Storage: ‘gcs’ / ‘google_storage’ / ‘google storage’ Everything else results just in local storage to disk

  • bucket_name (str) – name of the bucket in the cloud storage

  • cloud_dir_prefix (str) – path to the folder inside the bucket where the experiments are going to be saved

  • **kwargs – additional arguments for torch.utils.tensorboard.SummaryWriter wrapped inside this callback

on_batch_end()[source]

Logic executed after the batch is inserted into the model

Returns:

None

on_epoch_end()[source]

Logic executed at the end of the epoch

Returns:

None