I have 128 vectors of embeddings
image.shape = torch.Size([128, 512])
text.shape = torch.Size([128, 512])
And I want to calculate the tensor containing the cosine similarity between all elements (i.e:
cosine.shape = torch.Size([128, 128])
Where the first row is the cosine similarity between the 1st image and all text (128), etc.
At the moment I'm only doing this, but the result is a one-dimension array containing only N cosine similarities.
cosine_similarity = torch.nn.CosineSimilarity()
cosine = cosine_similarity(image, text)
How can I do it? I tried to transpose text but didn't work