3

I know that theano.tensor.fourier.fft is essentially numpy.fft.fft. However, I was wondering if the inverse FFT was implemented? Namely, is there something like a theano.tensor.fourier.ifft, which is equivalent to numpy.fft.ifft?

I noticed that this has it, but I'm not sure how complete or reliable it is for doing what I want. Perhaps someone with a better understanding of Theano can weigh in here.

Also, if I were to use this sandbox Fourier, how would I go about doing it? Simply calling theano.sandbox.fourier.fft(x), where x is a 1D tensor, returns the error:

AttributeError: 'module' object has no attribute 'fourier'

Is there a way to fix this?

1
  • Show the code you've tried.
    – luoluo
    Aug 22, 2015 at 3:19

1 Answer 1

3

I can't comment on the robustness of the code but Theano as a whole is still in development (version 0.7) and this code is in the sandbox which should, I believe, be considered even less robust than the rest of Theano.

It's clear that this FFT operation is incomplete because it is currently incapable of computing gradients (note the TODO comments). If you need gradients then sorry, this operation isn't going to help (maybe you could finish it off and submit the enhancement?)

This implementation is just a shim around numpy's implementation so if numpy's implementation is sufficiently complete and reliable for doing what you want then this Theano shim probably is as well.

Note that because this just wraps numpy, it won't run on the GPU and if you're mixing this operation with other GPU enabled operations and running on a GPU then you're going to have a slowdown due to data being copied backwards and forwards between main and GPU memories.

To use this operation you'd do this:

import theano
import theano.sandbox.fourier as tsf

tsf.ifft(frames=..., n=..., axis=...)
4
  • Thanks, that really helps! Do you know of any FFT and IFFT Theano implementations that do compute the gradients?
    – user19346
    Aug 23, 2015 at 15:46
  • There's theano.tensor.fourier.fft (see github.com/Theano/Theano/blob/master/theano/tensor/fourier.py) which appears to support gradients, but not inverse FFT. Aug 23, 2015 at 16:58
  • Ok thanks. I think I can easily modify the theano tensor Fourier implementation to get inverse Fourier working with gradients and all.
    – user19346
    Aug 23, 2015 at 19:18
  • Granted, Theano at the moment does not support complex gradients, so implementing this does seem like a waste of time...
    – user19346
    Aug 24, 2015 at 15:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.