convolution using numpy/scipy using MKL libraries
hi all, Im trying to implement 3d convolutional networks.. for which I wanted to use convolve function from scipy.signal.convolve or fftconvolve.. but looks like both of them doesnot use MKL libraries.. is there any implementation of convolutoin which uses MKL libraries or MKL-threaded so that code runs faster. thanks a lot in advance *with regards..* *M. Sai Rajeswar* *M-tech Computer Technology* *IIT Delhi----------------------------------Cogito Ergo Sum---------*
Dear Sai, On 27.07.2014 10:28, Sai Rajeshwar wrote:
Im trying to implement 3d convolutional networks.. for which I wanted to use convolve function from scipy.signal.convolve or fftconvolve..
If MKL is not a hard requirement, you may consider using the awesome pyfftw interfacing the incredible FFTW along with a monkey patched version of fftconvolve. On monkey patching using pyfftw, see http://hgomersall.github.io/pyFFTW/sphinx/tutorial.html#quick-and-easy-the-p... This might be a good choice for "large" convolutions. Smaller convolutions might be better off with a "ordinary" convolution not using the convolution theorem. In case you learn about other solutions, please let us know what you've found. Regards Alex
hi alex, i didnot get..exactly how to perform convolution with pyFFT... the link introduces fft.. but not about convolution... any pointers about how to perform 3d convolution would be great.. thanks *with regards..* *M. Sai Rajeswar* *M-tech Computer Technology* *IIT Delhi----------------------------------Cogito Ergo Sum---------* On Sun, Jul 27, 2014 at 5:27 PM, Alexander Eberspächer < alex.eberspaecher@gmail.com> wrote:
Dear Sai,
On 27.07.2014 10:28, Sai Rajeshwar wrote:
Im trying to implement 3d convolutional networks.. for which I wanted to use convolve function from scipy.signal.convolve or fftconvolve..
If MKL is not a hard requirement, you may consider using the awesome pyfftw interfacing the incredible FFTW along with a monkey patched version of fftconvolve.
On monkey patching using pyfftw, see
http://hgomersall.github.io/pyFFTW/sphinx/tutorial.html#quick-and-easy-the-p...
This might be a good choice for "large" convolutions. Smaller convolutions might be better off with a "ordinary" convolution not using the convolution theorem.
In case you learn about other solutions, please let us know what you've found.
Regards
Alex _______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
On 27 July 2014 14:27, Sai Rajeshwar <rajsai24@gmail.com> wrote:
i didnot get..exactly how to perform convolution with pyFFT... the link introduces fft.. but not about convolution... any pointers about how to perform 3d convolution would be great..
The convolution of two functions is a product in Fourier space. So, the convolution of f with g is: IFT(FT(f) · FT(g)) There performing the FT is expensive, but multiplying is cheap. Depending on the size and if you are reusing arrays, it may be faster. Note that the same thing is true in arbitrary dimensions (depending on your definitions, there may be some factors missing). /David
Sai Rajeshwar <rajsai24@gmail.com> wrote:
i didnot get..exactly how to perform convolution with pyFFT... the link introduces fft.. but not about convolution... any pointers about how to perform 3d convolution would be great..
Just use the three-dimesional FFT. Convolution is always IFFT( FFT(x) * FFT(y) ). The same principles as for 1D FFT convolution applies, such as appropriate zero padding (on all three dimensions!) to avoid circular convolution. Consult any DSP textbook. You probably want numpy.fft.rfftn and numpy.fft.irfftn, unless your signals have complex numbers. As noted on the other mailing list, these functions will use MKL with Enthought Canopy, but not with a vanilla NumPy. Sturla
hi Sturla, I haven't used Enthought Canopy before.. so this does use MKL- libraries.. thanks also, any resources on how to use Enthought Canopy's numpy or fft would br great thank you *with regards..* *M. Sai Rajeswar* *M-tech Computer Technology* *IIT Delhi----------------------------------Cogito Ergo Sum---------* On Sun, Jul 27, 2014 at 10:17 PM, Sturla Molden <sturla.molden@gmail.com> wrote:
Sai Rajeshwar <rajsai24@gmail.com> wrote:
i didnot get..exactly how to perform convolution with pyFFT... the link introduces fft.. but not about convolution... any pointers about how to perform 3d convolution would be great..
Just use the three-dimesional FFT. Convolution is always IFFT( FFT(x) * FFT(y) ). The same principles as for 1D FFT convolution applies, such as appropriate zero padding (on all three dimensions!) to avoid circular convolution. Consult any DSP textbook.
You probably want numpy.fft.rfftn and numpy.fft.irfftn, unless your signals have complex numbers.
As noted on the other mailing list, these functions will use MKL with Enthought Canopy, but not with a vanilla NumPy.
Sturla
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
(Dropping scipy-dev from the CC list since this is more of a user question) You might also look into Theano; fast convolutional networks are a specialty of theirs. -n On 27 Jul 2014 09:28, "Sai Rajeshwar" <rajsai24@gmail.com> wrote:
hi all,
Im trying to implement 3d convolutional networks.. for which I wanted to use convolve function from scipy.signal.convolve or fftconvolve.. but looks like both of them doesnot use MKL libraries.. is there any implementation of convolutoin which uses MKL libraries or MKL-threaded so that code runs faster.
thanks a lot in advance
*with regards..*
*M. Sai Rajeswar* *M-tech Computer Technology*
*IIT Delhi----------------------------------Cogito Ergo Sum---------*
_______________________________________________ SciPy-Dev mailing list SciPy-Dev@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-dev
participants (5)
-
Alexander Eberspächer
-
Daπid
-
Nathaniel Smith
-
Sai Rajeshwar
-
Sturla Molden