Open rpadams opened 10 years ago
Hi,
I came across kayak looking for a quick way to implement a convolution network in Python. I have a few questions about your 1d convolution implementation:
1.) What is the 1d convolution you are implementing? Since A and B are allowed to be higher dimensional I assumed it was supposed to compute the row-by-row convolution of the respective tensors, but when ncolors is set to 1, this appears not to be the case - it just computes the matrix product of A and B.
2.) The output of the _local_grad operation appears to have the same dimensionality as the inputs. Shouldn't it be greater? The gradient of a function from R^n x R^n to R^n by the first (weight) parameter should live in R^2n. In the case that A and B are matrices, the gradient with respect to A should be 4-dimensional, but _local_grad returns a matrix.
My apologies if these are dumb questions - I'm a mathematician with very minimal programming experience.
Thanks for your consideration, Shawn
Hi Shawn, sorry the documentation could be much better here (and I should change the word colors to maybe "channels" instead)
The input should be of the form NxD where N is the number of examples (e.g. training cases) and D is the dimensionality of the input (length of the sequence) times the number of channels. The convolution is then applied N times along the 2nd dimension (i.e. over the D dimensional input). When there are multiple input channels (e.g. analogous to multiple colors in the 2D convolution case) we assume that they are stacked horizontally in the second dimension (i.e. [first channel, second channel, ..., etc.]) such that you could reshape the inputs to be a tensor of shape (N, nchannels, D) and then the convolution of a nchannel x filter_size filter is applied along the D dimension.
Local_grad returns the matrix of the partial derivatives of the inputs (self.A or self.B) with respect to the output of the function, so it will return the gradient w.r.t. each element in the input (thus be the same size as the input).
Hope that helps!
Jasper
Hi,
I'm sorry, but I still don't understand. If I explain what I want to do, can you tell me if Convolve1d can do it, and if so, how?
What I want to do is input a kxm matrix A, which I think of as a list of m column vectors of length k, and a kxn matrix B, which I think of as a list of k row filters of length n (where generally n < m). I want the output to be the wide row by row convolution of A by B, that is, the kx(m+n-1) matrix whose ith row is the wide 1d convolution A[i,:]*B[i,:].
Is this possible?
Thanks, Shawn
Shawn, you should check out autograd: https://github.com/HIPS/autograd. It's probably much easier for you to use since you can just use plain python and numpy functions. There is a convolutional network example at: https://github.com/HIPS/autograd/blob/master/examples/convnet.py
Best,
Jasper
On Mon, Apr 13, 2015 at 4:13 PM, shawnjhenry notifications@github.com wrote:
Hi,
I'm sorry, but I still don't understand. If I explain what I want to do, can you tell me if Convolve1d can do it, and if so, how?
What I want to do is input a kxm matrix A, which I think of as a list of m column vectors of length k, and a kxn matrix B, which I think of as a list of k row filters of length n (where generally n < m). I want the output to be the wide row by row convolution of A by B, that is, the kx(m+n-1) matrix whose ith row is the wide 1d convolution A[i,:]*B[i,:].
Is this possible?
Thanks, Shawn
— Reply to this email directly or view it on GitHub https://github.com/HIPS/Kayak/issues/2#issuecomment-92484334.
Thanks, I'll have a look.
Shawn
1D convolutions are done. We should change this request to be 2D convolutions.