Stuck on deconvolution in Theano and TensorFlow



I'm captivated by autoencoders and really like the idea of convolution. It seems though that both Theano and TensorFlow only support conv2d to go from an array of 2D-RGB (n 3D arrays) to an array of higher-depth images. That makes sense from the traditional tensor-product math, c_ijkl = sum{a_ijk*b_klm}, but means it's hard to 'de-convolve' an image.

In both cases, if I have an image (in #batch, depth, height, width form), I can do a conv to get (#batch, num_filters, height/k, width/k). I'd really like to do the opposite, like going from (#batch, some_items, height/k, width/k) to (#batch, depth, height, width).

TensorFlow had the hidden deconv2d function for a while (in 0.6, I think, undocumented), but I'd like to know if there's a math trick I can use to get a bigger output in the last two dimensions after a convolution than the input. I'd settle for a series of differentiable operations, like conv -> resize, but I want to avoid just doing a dense matrix multiplication -> resize like I've been doing so far.

EDIT: As of today (2016/02/17) TensorFlow 0.7 has the tf.depth_to_space method, which helps greatly in this endeavor. ( I would still love a Theano based solution, too, to complete my understanding of the material.

Joseph Catrambone

Posted 2016-02-09T19:43:01.207

Reputation: 193



Things have changed in TensorFlow since this question was asked but here is a link to doing conv2d_transpose. I think thats what you are looking for


Posted 2016-02-09T19:43:01.207

Reputation: 26


Maybe have a look at this post. You can do a convolution which produces an output of similar size and then "unpool" those feature maps.


Posted 2016-02-09T19:43:01.207

Reputation: 11

Alas, I've seen this link. Thank you, though. The reason it didn't fit for me was it relied on tiling the output for a 2x upscaling. I could perhaps do as you suggested and produce a feature vector much larger than the convolution output, then resize, but it'll take me a while to figure out how that reshape changes the flow of data. – Joseph Catrambone – 2016-03-21T23:20:41.257


Not sure if you're looking for filter weights in the deconvolutional layer to be tied to corresponding convolutional layer, but either is possible in Lasagne which runs on Theano. An untied implementation of deconvolutional layer which outputs an image larger than its input:!topic/lasagne-users/9H6-mmnkHX0


Posted 2016-02-09T19:43:01.207

Reputation: 1