CosineSimilarity
- class torch.nn.CosineSimilarity(dim=1, eps=1e-08)
Returns cosine similarity between and , computed along .
Returns cosine similarity between and , computed along .
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:
>>> input1 = torch.randn(100, 128)
>>> input2 = torch.randn(100, 128)
>>> cos = nn.CosineSimilarity(dim=1, eps=1e-6)
>>> output = cos(input1, input2)
Runs the forward pass.