Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TensorFlow: Unpooling

Tags:

Is there TensorFlow native function that does unpooling for Deconvolutional Networks ?

I have written this in normal python, but it is getting complicated when want to translate it to TensorFlow as it's objects does not even support item assignment at the moment, and I think this is a great inconvenience with TF.

like image 761
VM_AI Avatar asked Apr 11 '16 12:04

VM_AI


People also ask

What is Unpooling in CNN?

Unpooling, as its name implies, attempts to perform exactly the opposite, restoring the size of original input feature map (in Fig2, from 2⨯2 to 4⨯4).

What is Max Unpooling?

The unpooling operation is used to revert the effect of the max pooling operation; the idea is just to work as an upsampler.

What is the name of the built in Tensorflow layer type which you can use to increase the dimensions of a 2D image?

Upsampling layer for 2D inputs.


2 Answers

I don't think there is an official unpooling layer yet which is frustrating because you have to use image resize (bilinear interpolation or nearest neighbor) which is like an average unpooling operation and it's reaaaly slow. Look at the tf api in the section 'image' and you will find it.

Tensorflow has a maxpooling_with_argmax thing where you get you maxpooled output as well as the activation map which is nice as you could use it in an unpooling layer to preserve the 'lost' spacial information but it seems as there isn't such an unpooling operation that does it. I guess that they are planning to add it ... soon.

Edit: I found some guy on google discuss a week ago who seems to have implemented something like this but I personally haven't tried it yet. https://github.com/ppwwyyxx/tensorpack/blob/master/tensorpack/models/pool.py#L66

like image 117
Shagas Avatar answered Oct 03 '22 09:10

Shagas


There is a couple of tensorflow implementations here pooling.py

Namely:

1) unpool operation (source) that utilizes output of tf.nn.max_pool_with_argmax. Although please notice, that as of tensorflow 1.0 tf.nn.max_pool_with_argmax is GPU-only

2) upsample operation that mimics inverse of max-pooling by filling positions of unpooled region with either zeros or copies of max element. Comparing to tensorpack it allows copies of elements instead of zeros and supports strides other than [2, 2].

No recompile, back-prop friendly.

Illustration: Upsampling

Unpooling

like image 39
y.selivonchyk Avatar answered Oct 03 '22 09:10

y.selivonchyk