[Numpy-discussion] tensordot bug when summing over same axis indexes?

josef.pktd at gmail.com josef.pktd at gmail.com
Tue Feb 24 15:20:36 EST 2009


On Tue, Feb 24, 2009 at 2:55 PM, Jose Borreguero <borreguero at gmail.com> wrote:
> The following example:
>
> from numpy import *
> a=arange(12).reshape(2,3,2)
> b=arange(24).reshape(2,3,2,2)
> c=tensordot( a,b,axes=([0,0],[1,1]) )
>
> defaults:
> c=tensordot( a,b,axes=([0,0],[1,1]) )
> File "/usr/lib/python2.4/site-packages/numpy/core/numeric.py", line 359, in
> tensordot
> raise ValueError, "shape-mismatch for sum"
> ValueError: shape-mismatch for sum
>
> Am I doing something really stupid, or is this a bug?
>
> -Jose

did you want to do this?

>>> c=np.tensordot( a,b,axes=([0,1],[0,1]) )
>>> c
array([[[440, 470],
        [500, 530]],

       [[500, 536],
        [572, 608]]])

Josef



More information about the NumPy-Discussion mailing list