This seems like a very odd thing to be doing.  Downsampling the frequency 
spectrum is (in the ideal case) equivalent to decreasing the field of view 
of the FFT on the original signal.  Why don't you just decrease the size of 
your original FFT?  That will make the FFT faster, and make your 
downsampling operation unnecessary.

On Monday, March 27, 2017 at 12:26:37 PM UTC-4, Torsten Knodt wrote:
>
> Hello,
> I am totally new to theano and have a first implementation to reduce the 
> resolution of the frequency axis of FFT data. My function basically sums 
> multiple consecutive bins to one, but also handles cases where the target 
> resolution is no integer multiple of the source resolution.
> from math import log2
> from numpy import array,arange,asarray,ceil,clip,empty,floor,trunc,
> frombuffer,save
> from theano import shared,function
> from theano.tensor import matrix,scalar,vector
>
> def resample(self, input_data, fsi, fso, fdo):
>   fsi = float(fsi)
>   fdi = fsi/len(input_data)
>   output_data = empty(shape=int(ceil(fso/fdo)))
>   for o in range(len(output_data)):
>     fmino = o*fdo
>     fnexto = (o+1)*fdo
>     _v = vector()
>     _i = scalar(dtype='int64')
>     _fdi = scalar()
>     _fmino = scalar()
>     _fnexto = scalar()
>     _f1 = function([_i,_fdi,_fmino,_fnexto,_v],(((_i+1)*_fdi).clip(_fmino,
> _fnexto)-(_i*_fdi).clip(_fmino,_fnexto))/_fdi*_v[_i])
>     output_data[o] = sum([_f1(i,fdi,fmino,fnexto,input_data) for i in 
> range(int(clip(floor(fmino/fdi),0,len(input_data)-1)),int(clip(ceil(fnexto
> /fdi), 1, len(input_data))))])
>   output_data = output_data / output_data.sum()
>   return output_data
>
> The background is, that I need fixed size FFT data to train a neuronal 
> network which shall do some classification of the input.
> What would be your recommendations to improve the performance of the 
> function? Improvements to efficiently handle multiple datasets of different 
> source frequency resolutions would be of special interest. Currently I only 
> work on my CPU, but plan to move to GPU later.
> input_data is already a numpy array. fsi specifies the maximum input 
> frequency, while fso specifies the maximum output frequency. fdo specifies 
> the requested resolution of the output.
>
> Thanks in Advance
>      Torsten Knodt
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to theano-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to