I have two batches of vectors: W= [w1,w2, w3,...]
and
V= [v1,v2,v3,...].
Both batches are expressed in numpy 2D vectors [[x1, y1], [x2,y2]...]
I want to calculate the pairwise dot product between any element in W and a element in V, and i want a matrix of possible combinations, ie
[ w1.v1, w1.v2, w1.v3,...
w2.v1, w2.v2, w2.v3,...
w3.v1, w3.v2, w3.v3,...
....................................... ]
if w and v are simple scalars then this is easy.
But the problem is w and v are 1D vectors: [x, y]
How do I implement this in numpy?
Thanks
Assuming that you want to compute the dot products of row vectors,
np.einsum('ji,ki-> jk', V, W)
If column vectors
np.einsum('ij,ik-> jk', V, W)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.