Is it possible to split long convolution to short ones? I use winograd convolution and I have functions for 2, 3 and 4 points. I need to perform winograd convolution for 8, 16 and 32 points. Can I combine already existing functions?
What I mean:
Iterated Convolution Algorithm (Description)
– 1. Decompose the long convolution into several levels of short
convolutions
– 2. Construct fast convolution algorithms for short convolutions
– 3. Use the short convolution algorithms to iteratively (hierarchically)
implement the long convolution
Related
In Fourier series, any function can be decomposed as sum of sine and
cosine
In neural networks, any function can be decomposed as weighted sum over logistic functions. (A one layer neural network)
In wavelet transforms, any function can be decomposed as weighted sum of Haar functions
Is there also such property for decomposition into mixture of Gaussians? If so, is there a proof?
If the sum allows to be infinite, then the answer is Yes. Please refer to Yves Meyer's book of "Wavelet and Operators", section 6.6, lemma 10.
There's a theorem, the Stone-Weierstrass theorem, which gives conditions for when a family of functions can approximate any continuous function. You need
an algebra of functions (closed under addition, subtraction, and
multiplication)
the constant functions
and you need the functions to separate points:
(for any two distinct points you can find a a function that assigns them different values)
You can approximate a constant function with increasingly wide gaussians. You can time-shift gaussians to separate points. So if you form an algebra out of gaussians, you can approximate any continuous function with them.
Yes. Decomposing any function to a sum of any kind of Gaussians is possible, since it can be decomposed to a sum of Dirac functions :) (and Dirac is a Gaussian where the variance approaches zero).
Some more interesting questions would be:
Can any function be decomposed to a sum of non-zero variance Gaussians, with a given, constant variance, that are defined around varying centers?
Can any function be be decomposed to a sum of non-zero variance Gaussians, all having 0 as the center, but defined with alternating variances?
The Mathematics Stack Exchange might be a better place to answer these questions though.
My aim is to classify types of cars (Sedans,SUV,Hatchbacks) and earlier I was using corner features for classification but it didn't work out very well so now I am trying Gabor features.
code from here
Now the features are extracted and suppose when I give an image as input then for 5 scales and 8 orientations I get 2 [1x40] matrices.
1. 40 columns of squared Energy.
2. 40 colums of mean Amplitude.
Problem is I want to use these two matrices for classification and I have about 230 images of 3 classes (SUV,sedan,hatchback).
I do not know how to create a [N x 230] matrix which can be taken as vInputs by the neural netowrk in matlab.(where N be the total features of one image).
My question:
How to create a one dimensional image vector from the 2 [1x40] matrices for one image.(should I append the mean Amplitude to square energy matrix to get a [1x80] matrix or something else?)
Should I be using these gabor features for my purpose of classification in first place? if not then what?
Thanks in advance
In general, there is nothing to think about - simple neural network requires one dimensional feature vector and does not care about the ordering, so you can simply concatenate any number of feature vectors into one (and even do it in random order - it does not matter). In particular if you have same feature matrices you also concatenate each of its row to create a vectorized format.
The only exception is when your data actually has some underlying geometrical dependicies, for example - matrix is actualy a pixels matrix. In such case architectures like PyraNet, Convolutional Neural Networks and others, which apply some kind of receptive fields based on this 2d structure - should be better. But those implementations simply accept 2d feature vector as an input.
There are two alternative methods to compute DCT and its inverse in MATLAB. One is dct2/idct2 and the other is the transformation matrix computed by dctmtx. Why is there an alternative way based on matrix multiplications making use of dctmtx?
"If A is square, the two-dimensional DCT of A can be computed as D*A*D'. This computation is sometimes faster than using dct2, especially if you are computing a large number of small DCTs, because D needs to be determined only once."
Where D = dctmtx(n)
Source: http://www.mathworks.com/help/toolbox/images/ref/dctmtx.html
I have a two vectors of spatial data (each about 2000 elements in length). One is a convolved version of the other. I am trying to determine the kernel that would produce such a convolution. I know that I can do this by finding the inverse Fourier transform of the ratio of the Fourier transforms of the output and input vectors. Indeed, when I do this I get more or less the shape I was expecting. However, my kernel vector has the same dimensionality as the two input vectors when in reality the convolution was only using about one fifth (~300-400) of the points. The fact that I am getting the right shape but the wrong number of points makes me think that I am not using the ifft and fft functions quite correctly. It seems like if I were really doing the right thing this should happen naturally. At the moment I am simply doing;
FTInput = fft(in);
FtOutput = fft(out);
kernel = ifft(FtOutput./FTInput).
Is this correct and it's up to me to interpret the output vector correctly or have I oversimplified the task? I'm sure it's the latter, I'm just not sure where.
Thanks
You are doing things correctly, this is not a bug.
The problem of estimating a convolution filter given clean and convolved data is VERY HARD. Given "nice" data, you may get the right shape but retrieving the true support of the convolution filter (i.e. getting zeroes where they should be) is NOT going to happen naturally.
I think your ''problem'' comes from the inherent padding necessary for discrete convolution that your are neglecting
By dividing in fourier, you assume your convolution was made with a cyclic padding in the spatial (or that your convolution was made by multiplication in fourier, both are equivalent) but if your convolution was computed in the spatial domain, a zero padding was most likely used.
s=[1 2 3 4 5] //signal
f=[0 1 2 1 0] //filter
s0=s *conv0* f=[4 8 12 16 14] //convolution with zero padding in spatial domain, truncated to signal length
sc=s *convc* f=[9 8 12 16 15] //convolution with cyclic padding in spatial domain, truncated to signal length
S,S0,Sc, the ffts of s,s0,sc
approx0=ifft(S0./S)=[-0.08 1.12 2.72 -0.08 -0.08]
approxc=ifft(Sc./S)=[0 1 2 1 0]
I applied a Gaussian low pass filter on an image using MATLAB for different standard deviations and recorded the time each method takes. I saw that implementing the filter in the frequency domain is much more efficient (faster). Does anyone has an explanation for this?
Assuming that you use imfilter, this function performs a convolution of the original image with the kernel (the gaussian filter image).
For going into the frequency domain and back, fast fourier transform (FFT) algorithms are used, and only an image multiplication is performed in the frequency domain.
imfilter will therefore take about N.M operations, being N and M the number of pixels in the image and kernel respectively.
Each of FFT or its inverse have complexity N log_2 N, and the multiplication has complexity N, for a total complexity of approximately N log_2 N, which is much faster than the convolution.