Reputation: 563
I have read this question here which seems similar, but my question may be simpler.
I have a matrix A that is of size [N x C], and a matrix X that is of size [N x D]
For each nth row in A, compute it's outer product with the corresponding nth row in X. Each outer product will yield a matrix, of size [C x D]. Then, sum up all those matricies together to get the final matrix.
Is there a simple non-for-loop way to do this in Python?
Thanks!
Upvotes: 0
Views: 115
Reputation: 15206
Take the nth rows outer: element (c,d) is A[n,c]*X[n,d]. Now sum over all n and you get Sum_n A[n,c]*X[n,d] which is exactly (AT.X)[c,d]
Upvotes: 1