PCALossο
- class lightning_pose.losses.losses.PCALoss[source]ο
Bases:
LossPenalize predictions that fall outside a low-dimensional subspace.
Attributes Summary
Methods Summary
__call__(keypoints_pred[,Β stage])Call self as a function.
compute_loss(predictions)remove_nans(**kwargs)Attributes Documentation
- LOSS_NAME_MULTIVIEW = 'pca_multiview'ο
- LOSS_NAME_SINGLEVIEW = 'pca_singleview'ο
Methods Documentation
- __call__(keypoints_pred: Tensor, stage: Literal['train', 'val', 'test'] | None = None, **kwargs) tuple[~torch.Annotated[~torch.Tensor, {'__torchtyping__': True, 'details': ((),), 'cls_name': 'TensorType'}], list[dict]][source]ο
Call self as a function.
- compute_loss(predictions: Tensor, {'__torchtyping__': True, 'details': ('num_samples', 'sample_dim'), 'cls_name': 'TensorType'}]) Tensor, {'__torchtyping__': True, 'details': ('num_samples', -1,), 'cls_name': 'TensorType'}][source]ο
- __init__(loss_name: Literal['pca_singleview', 'pca_multiview'], components_to_keep: int | float = 0.95, empirical_epsilon_percentile: float = 99.0, epsilon: float | None = None, empirical_epsilon_multiplier: float = 1.0, mirrored_column_matches: ListConfig | list | None = None, columns_for_singleview_pca: ListConfig | list | None = None, data_module: BaseDataModule | UnlabeledDataModule | None = None, log_weight: float = 0.0, device: Literal['cpu', 'cuda'] | device = 'cpu', centering_method: Literal['mean', 'median'] | None = None, **kwargs) None[source]ο
Initialize PCALoss.
Fits a
KeypointPCAobject on the training data and uses the resulting low-dimensional subspace to penalize out-of-subspace predictions at training time.- Parameters:
loss_name β
"pca_singleview"penalizes single-camera predictions;"pca_multiview"penalizes predictions that are inconsistent across views.components_to_keep β passed to
KeypointPCA; see its docstring for details.empirical_epsilon_percentile β percentile of the training-data reprojection error used to set epsilon when
epsilonisNone; in[0, 100].epsilon β if not
None, use this fixed epsilon value and ignoreempirical_epsilon_percentile.empirical_epsilon_multiplier β scalar multiplier applied to the empirically computed epsilon before use.
mirrored_column_matches β required for
"pca_multiview"; seeKeypointPCAfor details.columns_for_singleview_pca β subset of keypoint indices to use for singleview PCA;
Noneuses all keypoints.data_module β data module used by
KeypointPCAto extract training data.log_weight β final weight in front of the loss term in the objective function is computed as
1.0 / (2.0 * exp(log_weight)).device β device on which PCA parameters are stored and loss is computed.
centering_method β if not
None, subtract the per-frame keypoint centroid before fitting PCA."mean"uses the arithmetic mean;"median"uses the median.
- __new__(**kwargs)ο