I have a Vector, M, with size N and a Tensor, d, with size NxNxD. My aim is to perform the matrix multication M*d[i,:,:] for each i to get a new matrix with size nxD. Now I could just do it like this: a = np.zeros((n,D)) for i in range(n): a = G*np.matmul(M,d[i,:,:]) but I'd prefer a one line solution if it exists. Anyone got any ideas? Continue reading...