Hello, I have two tensors. Tensor A is of size (n,d), and tensor B is of size (n, k, d). I want to calculate the cosine similarity for the first row of tensor A to each row of the first layer in Tensor B. Then to calculate the cosine similarity for the second row of tensor A to each row of the second layer in Tensor B. So on so forth as illustrated below:
I cannot think of a good way of doing it rather than using a for-loop. Can someone help me?