Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convolution #2

Open
rpadams opened this issue Jul 5, 2014 · 6 comments
Open

Convolution #2

rpadams opened this issue Jul 5, 2014 · 6 comments

Comments

@rpadams
Copy link
Contributor

rpadams commented Jul 5, 2014

No description provided.

@JasperSnoek
Copy link
Contributor

1D convolutions are done. We should change this request to be 2D convolutions.

@shawnjhenry
Copy link

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

@JasperSnoek
Copy link
Contributor

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

@shawnjhenry
Copy link

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

@JasperSnoek
Copy link
Contributor

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 [email protected]
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
#2 (comment).

@shawnjhenry
Copy link

Thanks, I'll have a look.

Shawn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants