[Numpy-discussion] confused about tensordot
Fri Feb 15 09:50:49 CST 2013
In the following code
c = np.multiply (a, b.conj())
d = np.abs (np.sum (c, axis=0)/rows)
d2 = np.abs (np.tensordot (a, b.conj(), ((0,),(0,)))/rows)
print a.shape, b.shape, d.shape, d2.shape
The 1st compute steps, where I do multiply and then sum give the result I want.
I wanted to try to combine these 2 steps using tensordot, but it's not
doing what I want.
The print statement outputs this:
(1004, 13) (1004, 13) (13,) (13, 13)
The correct output should be (13,), but the tensordot output is (13,13).
It's supposed to take 2 matrixes, each (1004, 13) and do element-wise multiply,
then sum over axis 0.
More information about the NumPy-Discussion