trackers package

Submodules

trackers.callbacks module

class trackers.callbacks.ImagePredictionLogger(val_samples, num_samples=32)[source]

Bases: Callback

Callback for logging image predictions during validation.

Parameters:
  • val_samples (tuple) – A tuple containing validation images and labels.

  • num_samples (int) – Number of samples to log. Default is 32.

on_validation_epoch_end(trainer, pl_module)[source]

Method called at the end of each validation epoch.

Parameters:
  • trainer (Trainer) – The PyTorch Lightning Trainer object.

  • pl_module (LightningModule) – The PyTorch Lightning module being trained.

trackers.wandb module

trackers.wandb.is_square(num)[source]

Check if a number is a perfect square.

Parameters:

num (int) – The number to be checked.

Returns:

True if the number is a perfect square, False otherwise.

Return type:

bool

class trackers.wandb.WandbTracker(project_name, hyperparameters, tags, group, *args, **kwargs)[source]

Bases: object

Parameters:
observe_model(model, log_freq=1000)[source]

Observes the given model using Weights & Biases (wandb) library.

Parameters:
  • model (nn.Module) – The model to be observed.

  • log_freq (int, optional) – The frequency at which to log the model. Defaults to 1000.

Return type:

None

log(metrics)[source]

Logs the given metrics using WandB.

Parameters:

metrics (dict) – A dictionary containing the metrics to be logged.

Returns:

None

Return type:

None

log_images(images)[source]

Logs a grid of images and individual images to WandB.

Parameters:

images (torch.Tensor) – A tensor containing the images to be logged.

Raises:

AssertionError – If the number of images is not a square number.

Return type:

None

finish()[source]

Finish the tracking run and save the results.

get_experiment_name()[source]

Get the name of the current experiment.

Returns:

The name of the experiment.

Return type:

str

save_model(model_path)[source]

Save the model to the specified path using wandb.save.

Parameters:

model_path (str) – The path where the model should be saved.

Return type:

None

update_step()[source]

Increments the step counter by 1.

Return type:

None

Module contents

class trackers.WandbTracker(project_name, hyperparameters, tags, group, *args, **kwargs)[source]

Bases: object

Parameters:
observe_model(model, log_freq=1000)[source]

Observes the given model using Weights & Biases (wandb) library.

Parameters:
  • model (nn.Module) – The model to be observed.

  • log_freq (int, optional) – The frequency at which to log the model. Defaults to 1000.

Return type:

None

log(metrics)[source]

Logs the given metrics using WandB.

Parameters:

metrics (dict) – A dictionary containing the metrics to be logged.

Returns:

None

Return type:

None

log_images(images)[source]

Logs a grid of images and individual images to WandB.

Parameters:

images (torch.Tensor) – A tensor containing the images to be logged.

Raises:

AssertionError – If the number of images is not a square number.

Return type:

None

finish()[source]

Finish the tracking run and save the results.

get_experiment_name()[source]

Get the name of the current experiment.

Returns:

The name of the experiment.

Return type:

str

save_model(model_path)[source]

Save the model to the specified path using wandb.save.

Parameters:

model_path (str) – The path where the model should be saved.

Return type:

None

update_step()[source]

Increments the step counter by 1.

Return type:

None

trackers.get_tracker_class(tracker)[source]

Get tracker class by name.

Parameters:

tracker (str) – The name of the tracker.

Returns:

The tracker class.

Return type:

WandbTracker

Raises:

ValueError – If the tracker is not found.

class trackers.ImagePredictionLogger(val_samples, num_samples=32)[source]

Bases: Callback

Callback for logging image predictions during validation.

Parameters:
  • val_samples (tuple) – A tuple containing validation images and labels.

  • num_samples (int) – Number of samples to log. Default is 32.

on_validation_epoch_end(trainer, pl_module)[source]

Method called at the end of each validation epoch.

Parameters:
  • trainer (Trainer) – The PyTorch Lightning Trainer object.

  • pl_module (LightningModule) – The PyTorch Lightning module being trained.