CosineSimilarity¶
-
class
torch.nn.
CosineSimilarity
(dim=1, eps=1e-08)[source]¶ Returns cosine similarity between and , computed along dim.
- Parameters
- Shape:
Input1: where D is at position dim
- Input2: , same number of dimensions as x1, matching x1 size at dimension dim,
and broadcastable with x1 at other dimensions.
Output:
- Examples::
>>> input1 = torch.randn(100, 128) >>> input2 = torch.randn(100, 128) >>> cos = nn.CosineSimilarity(dim=1, eps=1e-6) >>> output = cos(input1, input2)