tensordot bug when summing over same axis indexes?
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
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
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@gmail.com> wrote:
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 _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
participants (2)
-
Jose Borreguero -
josef.pktd@gmail.com