Thursday, December 19, 2013

numpy dot vs inner

dot and inner returns the same result for 1D arrays.
However, for 2D arrays (matrices), dot gives the matrix product, whereas inner gives the sum-product over the last axis.

References
inner vs. dot
inner document
dot document

what is sum product?
A = [[x1, x2], [x3, x4]]
B = [[y1, y2], [y3, y4]]

sum product of A and B is given by numpy.inner(A,B) as follows
A's row i is element-wise multiplied by B's row j and the values are added to get the (i,j) element

[[x1*y1+x2*y2, x1*y3+x2*y4], [x3*y1+x4*y2, x3*y3+x4*y4]]

Continuously monitor GPU usage

 For nvidia GPUs do the follwing: nvidia-smi -l 1