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

josef.pktd@gmai... josef.pktd@gmai...
Tue Feb 24 14:20:36 CST 2009


On Tue, Feb 24, 2009 at 2:55 PM, Jose Borreguero <borreguero@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