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

Jose Borreguero borreguero at gmail.com
Tue Feb 24 15:44:04 EST 2009


haha, so it was a stupid error...my stupid error. [?]

I incorrectly understood ([0,0],[1,1]) as index 0 of *a* summed with index 0
of *b*, and analogously for [1,1].

Gthanks, Josef

On Tue, Feb 24, 2009 at 3:20 PM, <josef.pktd at gmail.com> wrote:

> 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
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20090224/b95e6faa/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 32F.gif
Type: image/gif
Size: 104 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20090224/b95e6faa/attachment.gif>


More information about the NumPy-Discussion mailing list