I'm doing a research about personality identification based on their signature using CNN method, however the learning feature for the personality traits have a different input size. I understand that in CNN we have to make the same size for the input, but can I make the input size in different size?

I am using Recognition of Handwriting Based on Signature and Digit of Character Using Multiple of Artificial Neural Networks in Personality Identification as a reference for the learning feature.

  • $\begingroup$ This post should be closed 2 years ago, in the end I used AlexNet CNN with a customized layer configuration. Thanks to all who have been reaching out. $\endgroup$ Nov 24, 2022 at 6:13

2 Answers 2


If you build your network as a pure CNN, namely FCNN, then the network itself can support any input size.

Usually the issue is the data type of the batch.
For performance the container of a batch is a contiguous array, for example in PyTorch it is called a tensor. This tensor requires that all samples along any dimensions will have the same dimensions.

There are few ways around it:

  1. Set the batch size to 1
    This will hurt performance but is probably the easiest solution.

  2. Create a dedicated loader
    This loader will select from a pre defined list of samples with the same dimensions. It will ruin the randomness of the batches but will benefit run time performance.

  3. Pad / Sample all elements to the same size
    One may pad all samples to have the same size (Of the max size per dimension in the batch). In cases it makes sense you may use resampling / interpolation.

In case you have a Fully Connected / Dense layer somewhere you may do something to stabilize the number of inputs to that layer regardless of the input size. A simple trick is using a global maximum per channel. This means the output depends only on the number of channels.
A generalization is max pooling over a relative size of the image. Namely split it into quarters and have a global operator over it.

This is basically the idea in Spatial Pyramid Pooling in Deep Convolutional Networks for Visual Recognition.


You can research "Spatial Pyramid Pooling (SPP)" Btw, as far as I know, you don't need make same size for input for convolutional layer but FCN layer

Spatial Pyramid Pooling (SPP) is a pooling layer that removes the fixed-size constraint of the network, i.e. a CNN does not require a fixed-size input image. Specifically, we add an SPP layer on top of the last convolutional layer. The SPP layer pools the features and generates fixed-length outputs, which are then fed into the fully-connected layers (or other classifiers). In other words, we perform some information aggregation at a deeper stage of the network hierarchy (between convolutional layers and fully-connected layers) to avoid the need for cropping or warping at the beginning.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.