Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fully convolutional autoencoder for variable-sized images in keras

I want to build a convolutional autoencoder where the size of the input in not constant. I'm doing that by stacking up conv-pool layers until I reach an encoding layer, and then doing the reverse with upsample-conv layers. the problem is that no matter what settings I use, I can't get the exact same size in the output layer as the input layer. The reason for that is that the UpSampling layer (given say (2,2) size), doubles the size of the input, so I can't get odd dimensions for instance. Is there a way to tie the output dimension of a given layer to the input dimension of a previous layer for individual samples (as I said, the input size for the max-pool layer in variable)?

like image 979
izikgo Avatar asked Aug 16 '16 10:08

izikgo


People also ask

What is convolutional variational autoencoder?

Variational Autoencoder (VAE) Autoencoder is a neural network that is designed for unsupervised learning. It consists of 2 parts: encoder and decoder. The encoder aims to encode input features into encoding vectors, whereas the decoder obtains the output features back from the encoding vector.

Can autoencoders be used for image classification?

An autoencoders for image classification can take as input a distorted/transformed input image and can reconstruct the original good image. In the below example, the autoencoders for image classification will learn during training that the 3 distorted images on the LHS are same as the good image on the RHS.

Is an autoencoder a CNN?

Essentially, an autoencoder learns a clustering of the data. In contrast, the term CNN refers to a type of neural network which uses the convolution operator (often the 2D convolution when it is used for image processing tasks) to extract features from the data.

Are autoencoders convolutional?

2.3.Convolutional autoencoders (CAEs) are unsupervised dimensionality reduction models composed by convolutional layers capable of creating compressed image representations [28].


1 Answers

Yes, there is.

You can use three methods

  • Padding
  • Resizing
  • Crop or Pad

Padding will only work to increase the dimensions. Not beneficial for reducing the size.

Resizing should be more costly but optimum solution for each case (up or downsampling). It will keep all the values in the range and will simply resample them to resize in a given dimension.

Crop or Pad will work as resize and it will be more compute-efficient as there is no interpolation in this method. However, if you want to resize it to a smaller dimension, it will crop from the edges.

By using those 3, you can arrange your layer's dimensions.

like image 113
Deniz Beker Avatar answered Sep 21 '22 23:09

Deniz Beker