
Last chance! 50% off unlimited learning
Sale ends in
Cosine_similarity
torch_cosine_similarity(x1, x2, dim = 2L, eps = 0)
(Tensor) First input.
(Tensor) Second input (of size matching x1).
(int, optional) Dimension of vectors. Default: 1
(float, optional) Small value to avoid division by zero. Default: 1e-8
Returns cosine similarity between x1 and x2, computed along dim.
# NOT RUN {
if (torch_is_installed()) {
input1 = torch_randn(c(100, 128))
input2 = torch_randn(c(100, 128))
output = torch_cosine_similarity(input1, input2)
output
}
# }
Run the code above in your browser using DataLab