import numpy as np a = np.random.rand(5,5,3) b = np.random.rand(5,5) c = np.einsum('ijk,ij->ijk', a, b) print(c.shape) # c will have dimensions (5,5,3) # remove '#' from the line below to see results #print(c)