15 Feb
2013
15 Feb
'13
9:04 p.m.
It's supposed to take 2 matrixes, each (1004, 13) and do element-wise multiply, then sum over axis 0.
Can I use tensordot to do what I want?
No. In your case I'd just do (a*b.conj()).sum(0). (Assuming that a and b are arrays, not matrices). It is most helpful to think of tensordot as a generalization on matrix multiplication where the axes argument gives the axes of the first and second arrays which should be summed over. a = np.random.rand(4,5,6,7) b = np.random.rand(8,7,5,2) c = np.tensordot(a, b, axes=((1, 3), (2, 1))) # contract over dimensions with size 5 and 7 assert c.shape == (4, 6, 8, 2) # the resulting shape is the shape given by a.shape + b.shape, which contracted dimensions removed. -Brad