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

Purpose of image_shape and filter_shape in conv2D_keep_shape? #5

Open
hi-abhi opened this issue Dec 28, 2016 · 4 comments
Open

Purpose of image_shape and filter_shape in conv2D_keep_shape? #5

hi-abhi opened this issue Dec 28, 2016 · 4 comments

Comments

@hi-abhi
Copy link

hi-abhi commented Dec 28, 2016

In your conv2d_keep_shape function which I copied below what is the purpose of the image_shape and filter_shape args?

def conv2D_keep_shape(x, w, image_shape, filter_shape, subsample=(1, 1)):
    # crop output to same size as input
    fs = T.shape(w)[2] - 1  # this is the filter size minus 1
    ims = T.shape(x)[2]     # this is the image size
    return theano.sandbox.cuda.dnn.dnn_conv(img=x,
                                            kerns=w,
                                            border_mode='full',
                                            subsample=subsample,
                                            )[:, :, fs/2:ims+fs/2, fs/2:ims+fs/2]

The parameters exist when you call the function every time you want to do a convolution, but they aren't being used in anyway. For example:

self.h = conv2D_keep_shape(in_x, self.w0, image_shape=[batchsize, self.w0.shape.eval()[1], imsize[0], imsize[1]], filter_shape=self.w0.shape.eval())

Are they intended to be used somehow or is this a remnant of old code being refactored? I ask because I implemented this architecture in TensorFlow and am attempting to replicate the results.

@avivt
Copy link
Owner

avivt commented Dec 29, 2016

Hi,
This is indeed a remnant of old code.
The current code uses cuDNN for the convolution, which doesn't take as input the image_shape and filter_shape. Before I used the standard Theano conv2d (slower than cuDNN), which could take these parameters as input.
Actually, I see that now that Theano has a added features to their conv2d function to make it keep a smae shape convolution (http://deeplearning.net/software/theano/library/tensor/nnet/conv.html#theano.tensor.nnet.conv2d)
so I guess this whole function can be replaced by it.

Excited to see your tensorflow implementation!

@hi-abhi
Copy link
Author

hi-abhi commented Dec 29, 2016

I figured that was the case and just wanted to make sure. Tensorflow has a "SAME" padding for conv2d which does the same thing as well.

My implementation is here: https://github.com/TheAbhiKumar/tensorflow-value-iteration-networks

It converges for the 8x8, but I am still having trouble with the 16x16 and 28x28 domains. I am starting to suspect that my implementation isn't exactly the same as yours. TensorFlow's advanced indexing capabilities aren't as strong as NumPy or Theano's so I kind of have to hack around it by transposing, indexing separately and then using tf.gather_nd. I'll have to take a deeper look into it and see why I am not getting the expected results.

Also, do you have an ETA for when the datasets/code will be uploaded for the other experiments? I am interested in implementing the continuous control and webnav models.

@avivt
Copy link
Owner

avivt commented Dec 30, 2016 via email

@hi-abhi
Copy link
Author

hi-abhi commented Dec 30, 2016

I would appreciate that. Perhaps that implementation might help me figure out the issues with my implementation.

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

No branches or pull requests

2 participants