Given two numpy arrays of shape (25, 2), and (2,), one can easily multiply them across:
import numpy as np
a = np.random.rand(2, 25)
b = np.random.rand(2)
(a.T * b).T # ok, shape (2, 25)
I have a similar situation where b is of shape (2, 4), and I'd like to get the same results as above for all "4" b. The following works,
a = np.random.rand(25, 2)
b = np.random.rand(2, 4)
c = np.moveaxis([a * bb for bb in b.T], -1, 0) # shape (2, 4, 25)
but I have a hunch that this is possible without moveaxis.
Any ideas?