EuclideanDistance#
- class myoverse.models.components.losses.EuclideanDistance(n_joints=20, n_dims=3)[source]#
Euclidean distance loss for 3D joint positions.
Computes the mean Euclidean distance between predicted and ground truth 3D joint positions. Expects input tensors to be reshaped to (batch, joints, xyz).
- Parameters:
Examples
>>> loss_fn = EuclideanDistance(n_joints=20) >>> pred = torch.randn(32, 60) # batch_size=32, 20 joints * 3 dims >>> target = torch.randn(32, 60) >>> loss = loss_fn(pred, target)
Initialize internal Module state, shared by both nn.Module and ScriptModule.
Methods
__init__([n_joints, n_dims])Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(prediction, ground_truth)Compute the mean Euclidean distance loss.
- forward(prediction, ground_truth)[source]#
Compute the mean Euclidean distance loss.
- Parameters:
prediction (torch.Tensor) – Predicted joint positions, shape (batch, n_joints * n_dims).
ground_truth (torch.Tensor) – Ground truth joint positions, shape (batch, n_joints * n_dims).
- Returns:
Scalar loss value.
- Return type: