I have a numpy array a
of shape (x, y)
and another array b
of shape (x, z)
I'm trying to get the dot product between each row (dimension x
) of a
and b
. Desired result: x
amount of matrixes of shape (x, y)
or a matrix of shape (x, y, z)
.
dot
? Which axis are you summing? The result dimension looks more like an outer product.a[:,:,None] * b[:,None,:]
matmul
can also handle this by adding a size 1 dimension for thesum-of-products
,a[:,:,None]@b[:,None,:]