Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upsampling feature maps in TensorFlow

I want to implement a convolution-deconvolution network for a image segmentation project. In the deconvolution part, I am planning to upsample the feature map by 2. e.g. The original feature map is of dimension 64*64*4 and I want to upsample it into 128*128*4. Does anyone know a tensor operation that does this? Thanks!

like image 904
Wang Duo Avatar asked Apr 11 '16 11:04

Wang Duo


People also ask

How is Upsampling done in CNN?

In the Downsampling network, simple CNN architectures are used and abstract representations of the input image are produced. In the Upsampling network, the abstract image representations are upsampled using various techniques to make their spatial dimensions equal to the input image.

Why is Upsampling used in CNN?

Its role is to bring back the resolution to the resolution of previous layer. Theoretically, we can eliminate the down/up sampling layers altogether. However to reduce the number of computations, we can downsample the input before a layers and then upsample its output.

How Upsampling works?

It works by repeating the rows and columns of the input. A more elaborate approach is to perform a backwards convolutional operation, originally referred to as a deconvolution, which is incorrect, but is more commonly referred to as a fractional convolutional layer or a transposed convolutional layer.


1 Answers

You could use tf.image.resize_images(). It takes batches of images or single images and supports the most common methods such as bilinear and nearest_neighbor.

Here's the link to the TensorFlow API reference: resizing

You can also take a look at how the upsampling operation is implemented in a higher-level API such as tflearn. You can find upsample_2d and upscore_layer in their Github repo: conv.py

Note: the output might be cast to tf.float32 in older TF versions

like image 93
chillinger Avatar answered Oct 09 '22 21:10

chillinger