I have a bunch of 5-dimensional vectors of shape (5,)
in a 2-dimensional array of shape (1000, 5)
, each of which which I want to multiply by a matrix of shape (6, 5)
.
I would have assumed that broadcasting would allow me to do
A = np.random.rand(1000, 5)
B = np.random.rand(1, 6, 5) # empty axis for broadcasting
np.matmul(B, A)
but this doesn't work properly.
Is there a way to do this kind of multiplication so that np.matmul(B, A)
produces an output of shape (1000, 6)
?