HeatmapKLLoss

class lightning_pose.losses.losses.HeatmapKLLoss[source]

Bases: HeatmapLoss

Kullback-Leibler loss between heatmaps.

Attributes Summary

loss_name

Methods Summary

compute_loss(targets,Β predictions)

Compute per-keypoint KL divergence between target and predicted heatmaps.

Attributes Documentation

loss_name: str = 'heatmap_kl'

Methods Documentation

compute_loss(targets: Float[Tensor, 'num_valid_keypoints heatmap_height heatmap_width'], predictions: Float[Tensor, 'num_valid_keypoints heatmap_height heatmap_width']) Float[Tensor, 'num_valid_keypoints'][source]

Compute per-keypoint KL divergence between target and predicted heatmaps.

Parameters:
  • targets – ground-truth heatmaps.

  • predictions – model-predicted heatmaps.

Returns:

per-keypoint KL divergence values.

__init__(data_module: BaseDataModule | UnlabeledDataModule | None = None, log_weight: float = 0.0, **kwargs: Any) None[source]

Initialize HeatmapKLLoss.

Parameters:
  • data_module – data module providing access to datasets; passed to the parent class.

  • log_weight – final weight in front of the loss term in the objective function is computed as 1.0 / (2.0 * exp(log_weight)).

__new__(**kwargs)