0

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!

Community
  • 1
  • 1
TheGrapeBeyond
  • 543
  • 2
  • 8
  • 19

1 Answers1

1

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]

Julien
  • 13,986
  • 5
  • 29
  • 53