Hello,
I’m tring to calculate the cosine similarity between two tensors of different shapes:
tensor1: torch.Size([15, 24, 4, 120])
tensor2: torch.Size([5608, 4, 120])
To make them have the same dimension, I used unsqueeze to make them both of size
torch.Size([15, 24, 5608, 4, 120])
However, this new tensor makes me run out of memory because it has 969M elements and takes 3.8Gb.
Is there a better way to calculate cosine similarity without creating this giant tensor?