[Numpy-discussion] Multiplying list of matrices with list of vectors
Hi, I have a list of matrices W_k I'd like to multiply with a list of vectors v_k, or another way of looking at it, writing all W_k into a 3d array and all v_k into a 2d matrix/array, I'd like to compute matrix R as R_ik = sum_j W_ijk h_jk. Is there a fast way of doing that in numpy? Regards, David The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] defmatrix move and unpickling of old data
Hi, Just to let you know, I now fixed the problem using: import sys import numpy sys.modules['numpy.core.defmatrix'] = numpy.matrixlib.defmatrix The key is that the statement import numpy.core.defmatrix needs to work for unpickling to succeed, and just renaming things isn't enough. Cheers David On Sat, Apr 3, 2010 at 8:13 PM, David Reichert d.p.reich...@sms.ed.ac.ukwrote: Hi, After some work I got an optimized numpy compiled on a machine where I don't have root access, but I had to use numpy 1.4.0 to make it work. Now I have the problem that I cannot seem to unpickle data I had created using numpy 1.3, getting an ImportError about defmatrix not being found. I understand defmatrix was moved from core to matrixlib? Is there some workaround I could use? I might have to move my data in between machines with either versions of numpy installed in the future as well... I already tried some renaming tricks but to no avail. Thanks David The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] defmatrix move and unpickling of old data
Hi, After some work I got an optimized numpy compiled on a machine where I don't have root access, but I had to use numpy 1.4.0 to make it work. Now I have the problem that I cannot seem to unpickle data I had created using numpy 1.3, getting an ImportError about defmatrix not being found. I understand defmatrix was moved from core to matrixlib? Is there some workaround I could use? I might have to move my data in between machines with either versions of numpy installed in the future as well... I already tried some renaming tricks but to no avail. Thanks David The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Memory leak with matrices?
Thanks for the reply. Yes never mind the second issue, I had myself confused there. Any comments on the memory leak? On Tue, Mar 9, 2010 at 5:55 PM, josef.p...@gmail.com wrote: On Tue, Mar 9, 2010 at 12:31 PM, David Paul Reichert d.p.reich...@sms.ed.ac.uk wrote: Hi, I've got two issues: First, the following seems to cause a memory leak, using numpy 1.3.0: a = matrix(ones(1)) while True: a += 0 This only seems to happen when a is a matrix rather than an array, and when the short hand '+=' is used. Second, I'm not sure whether that's a bug or whether I just don't understand what's going on, but when a is a column array, (e.g. a = ones((10, 1))), then a -= a[0,:] only subtracts from a[0, 0], whereas not using the short hand or using something else than a on the righthand side seems to subtract from all rows as expected. this is because a[0,0] is set to zero after the first inplace subtraction, then zero is subtracted from all other rows a = np.ones((10, 1)) a array([[ 1.], [ 1.], [ 1.], [ 1.], [ 1.], [ 1.], [ 1.], [ 1.], [ 1.], [ 1.]]) a += a[0,:] a array([[ 2.], [ 3.], [ 3.], [ 3.], [ 3.], [ 3.], [ 3.], [ 3.], [ 3.], [ 3.]]) a -= a[0,:] a array([[ 0.], [ 3.], [ 3.], [ 3.], [ 3.], [ 3.], [ 3.], [ 3.], [ 3.], [ 3.]]) Josef Thanks a lot, David -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Memory leak in signal.convolve2d? Alternative?
Hm, upgrading scipy from 0.7.0 to 0.7.1 didn't do the trick for me (still running numpy 1.3.0). I'm not sure if I feel confident enough to use developer versions, but I'll look into it. Cheers David On Tue, Mar 9, 2010 at 7:57 PM, Robert Kern robert.k...@gmail.com wrote: On Tue, Mar 9, 2010 at 13:49, David Reichert d.p.reich...@sms.ed.ac.uk wrote: Hi, I just reported a memory leak with matrices, and I might have found another (unrelated) one in the convolve2d function: import scipy.signal from numpy import ones while True: scipy.signal.convolve2d(ones((1,1)), ones((1,1))) This does not leak for me using SVN versions of numpy and scipy. I recommend upgrading. -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Memory leak in signal.convolve2d? Alternative?
Hi, Just another update: signal.convolve and signal.fftconvolve indeed do not seem to have the problem, however, they are slower by at least a factor of 2 for my situation. Moreover, I also tried out the numpy 1.4.x branch and the latest scipy svn, and a short test seemed to indicate that the memory leak still was present (albeit, interestingly, memory usage grew much slower), but then something else stopped working in my main program, so I converted back to scipy 7.1 and numpy 1.3.0 for now. I might have confused things somewhere along the line, though, I'm not an expert with these things. Maybe other people can confirm the problem one way or another. Thanks, David On Tue, Mar 9, 2010 at 9:32 PM, josef.p...@gmail.com wrote: On Tue, Mar 9, 2010 at 4:24 PM, David Reichert d.p.reich...@sms.ed.ac.uk wrote: Hm, upgrading scipy from 0.7.0 to 0.7.1 didn't do the trick for me (still running numpy 1.3.0). I'm not sure if I feel confident enough to use developer versions, but I'll look into it. If you don't need the extra options, you could also use in the meantime the nd version signal.convolve or the fft version signal.fftconvolve Josef Cheers David On Tue, Mar 9, 2010 at 7:57 PM, Robert Kern robert.k...@gmail.com wrote: On Tue, Mar 9, 2010 at 13:49, David Reichert d.p.reich...@sms.ed.ac.uk wrote: Hi, I just reported a memory leak with matrices, and I might have found another (unrelated) one in the convolve2d function: import scipy.signal from numpy import ones while True: scipy.signal.convolve2d(ones((1,1)), ones((1,1))) This does not leak for me using SVN versions of numpy and scipy. I recommend upgrading. -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion