Category : tensor

# A: 14287 * 768 array, B: 863394 * 768 array def cosine_similarity(A,B): A = torch.tensor(A).to(‘cpu’) ; B = torch.tensor(B).to(‘cpu’) num = torch.mm(A, B.T) p1 = torch.sqrt(torch.sum(A**2, axis=1))[:, None] p2 = torch.sqrt(torch.sum(B**2, axis=1))[None, :] return (num/(p1*p2)).T The process gets killed when I do cosine similarity for the two matrices. I get the following logs on ..

Read more

I would like to make tensor, multiple multiple by 100, and then overwrite. This is what I want to do. a = torch.arange(3) >>>a tensor([ 0,1,2]) a = torch.mul(a, 100) >>>a tensor([0,100,200]) However, tensor do not allow me to overwrite. How can I preserve the result torch.mul(a, 100) ? Source: Python..

Read more