I have two tensors of size, t1 as [16,64,56,56] and t2 as [16,64,56,56]. Now I wanted to do perform dot product between two tensors to get final tensor with size as [16,64,16,64].
I needed this final tensor of required size so that I can again dot product this with t1 (as original features) in order to get refined features of original size [16,64,56,56]
How will I perform dot product between two tensors t1 and t2?
Note:- Something like in snapshot with attention matrix as CxC/2
Could you clarify what is dot product of 4D tensors?
Something like shown in snapshot dot product of CxH/2XW/2 and C/2xH/2xW/2 to get CxC/2.
Here it is just 3D tensor but in my case there is extra dimension as batch.
For dot_product you have several options:
torch.dot
expects a 1D
tensor
.
torch.mm
expects a 1D
or 2D
tensor
.
You can do torch.flatten(x) to get a 1D tensor.
torch.matmul
works for any rank but the output depends on the rank as expounded on in the docs.
https://pytorch.org/docs/stable/generated/torch.matmul.html