MCPcopy Create free account
hub / github.com/MotrixLab/ADHMR / get_pairwise_comp_probs

Function get_pairwise_comp_probs

ADHMR/lib/utils/relation.py:7–15  ·  view source on GitHub ↗
(batch_preds, batch_std_labels, sigma=None)

Source from the content-addressed store, hash-verified

5import torch.nn.functional as F
6
7def get_pairwise_comp_probs(batch_preds, batch_std_labels, sigma=None):
8 batch_s_ij = torch.unsqueeze(batch_preds, dim=2) - torch.unsqueeze(batch_preds, dim=1)
9 batch_p_ij = torch.sigmoid(sigma * batch_s_ij)
10
11 batch_std_diffs = torch.unsqueeze(batch_std_labels, dim=2) - torch.unsqueeze(batch_std_labels, dim=1)
12 batch_Sij = torch.clamp(batch_std_diffs, min=-1.0, max=1.0)
13 batch_std_p_ij = 0.5 * (1.0 + batch_Sij)
14
15 return batch_p_ij, batch_std_p_ij
16
17def rankloss(score, metric,mask=None,sigma=None):
18 gtrank = (-metric).argsort().argsort().float()

Callers 2

ranklossFunction · 0.70
lambdaranklossFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected