I have a few lines of code where I have a torch tensor
(200.000 x 512
) and I want to calculate the cosine distance between each of those embeddings.
Right now, I'm doing:
similarity = (image_features.cpu() @ image_features.cpu().T).squeeze()
But it takes too long. Maybe matlab is much faster. Does anyone can tell me how to do it there? (Convert my tensor to .mat file + code)