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