dgs.models.metric.metric.CosineSimilarityMetric¶
- class dgs.models.metric.metric.CosineSimilarityMetric(*args: Any, **kwargs: Any)[source]¶
Class to compute the cosine similarity between two matrices.
Notes
The cosine similarity is defined as:
\[\text{cosine similarity} = S_C(A,B) = \frac{\mathbf{A} \cdot \mathbf{B}}{\|\mathbf{A}\| \|\mathbf{B}\|}\]Methods
- forward(input1: torch.Tensor, input2: torch.Tensor) torch.Tensor [source]¶
Due to the sheer size of the
PoseTrack21
dataset,CosineSimilarity()
does not work due to memory issues. See this issue <https://github.com/pytorch/pytorch/issues/104564#issuecomment-1625348908>_ for more details.- Parameters:
input1 – tensor of shape
[a x E]
input2 – tensor of shape
[b x E]
- Returns:
tensor of shape
[a x b]
containing the distances.
References
https://github.com/pytorch/pytorch/issues/104564#issuecomment-1625348908