I am new to deep learning.

I have a dataset of images of varying dimensions of a certain object. A few images of the object are also in varying orientations. The objective is to learn the features of the object (using Autoencoders).

Is it possible to create a network with layers that account for varying dimensions and orientations of the input image, or should I strictly consider a dataset containing images of uniform dimensions? What is the necessary criteria of an eligible dataset to be used for training a Deep Network in general.

The idea is, I want to avoid pre-processing my dataset by normalizing it via scaling, re-orienting operations etc. I would like my network to account for the variability in dimensions and orientations. Please point me to resources for the same.

  • $\begingroup$ Can you provide example inputs? $\endgroup$
    – dynrepsys
    Commented Nov 29, 2016 at 3:48
  • $\begingroup$ Consider a dataset consisting of images of bananas. They are of varying sizes 265x525 px, 1200x1200 px, 165x520 px etc. 90% of the images display the banana in one orthogonal orientation and the rest display the banana in varying orientations such as isometric views.. I hope this helps $\endgroup$ Commented Nov 29, 2016 at 20:49

1 Answer 1


Almost always people will resize all their images to the same size before sending them to the CNN. Unless you're up for a real challenge this is probably what you should do.

That said, it is possible to build a single CNN that takes input of images as varying dimensions. There are a number of ways you might try to do this, and I'm not aware of any published science analyzing these different choices. The key is that the set of learned parameters needs to be shared between the different inputs sizes. While convolutions can be applied at different images sizes, ultimately they always get converted to a single vector to make predictions with, and the size of that vector will depend on the geometries of the inputs, convolutions and pooling layers. You'd probably want to dynamically change the pooling layers based on the input geometry and leave the convolutions the same, since the convolutional layers have parameters and pooling usually doesn't. So on bigger images you pool more aggressively.

Practically you'd want to group together similarly (identically) sized images together into minibatches for efficient processing. This is common for LSTM type models. This technique is commonly called "bucketing". See for example http://mxnet.io/how_to/bucketing.html for a description of how to do this efficiently.

  • 1
    $\begingroup$ what are the side-effects of resizing images into a fixed size? I mean once you fix it, you are bound to lose the aspect ratio of the images. $\endgroup$ Commented Jun 4, 2020 at 9:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .