CosineSimilarity¶
-
class
torch.nn.
CosineSimilarity
(dim: int = 1, eps: float = 1e-08)[source]¶ Returns cosine similarity between and , computed along dim.
- Parameters
- Shape:
Input1: where D is at position dim
Input2: , same shape as the Input1
Output:
- Examples::
>>> input1 = torch.randn(100, 128) >>> input2 = torch.randn(100, 128) >>> cos = nn.CosineSimilarity(dim=1, eps=1e-6) >>> output = cos(input1, input2)