<p>When you use CNN for classification task, your network has two part:</p>

<ol>
<li><p><em>Feature generator</em>. Part generates feature map with size <code>WF x HF</code> and <code>CF</code> channels by image with size <code>WI x HI</code> and <code>CI</code> channels . The relation between image sizes and feature map size depends of structure your NN (for example, on amount of pooling layers and stride of them).</p></li>
<li><p><em>Classifier</em>. Part solves the task of classification vectors with <code>WF*HF*CF</code> components into classes.</p></li>
</ol>

<p>You can put image with different size into <em>feature generator</em>, and get feature map with different sizes. But classifier can only be training on some fixed lengths vectors. Therefore you obviously train your network for some fixed sizes of images. If you have images with different size you resize it to input size of network, or crop some part of image.</p>

<p>Another way described in the article </p>

<p><em>K. He, X. Zhang, S. Ren, J. Sun, "Spatial pyramid pooling in deep convolutional networks for visual recognition," <a href="https://arxiv.org/abs/1406.4729" rel="nofollow noreferrer">arXiv:1406.4729</a> 2014</em></p>

<p>Authors offered <strong>Spatial pyramid pooling</strong>, which solve the problem with different image on the input of CNN. But I don't sure is spatial pyramid pooling layer exists in tensorflow.</p>
How to enable a Convolutional NN to take variable size input?
<p>So, I've seen that many of the first CNN examples in Machine Learning use the MNIST dataset. Each image there is 28x28, and so we know the shape of the input before hand. How would this be done for variable size input, let's say you have some images that are 56x56 and some 28x28.</p>

<p>I'm looking for a language and framework agnostic answer if possible or in tensorflow terms preferable</p>