Different results for different dimension in testing for trained model

cbd: <p>My model consist of convolution operations with skip connection. I trained model for 128x128 input dimension. During testing i give image of dimension 256x256. Results are differ in both the cases.</p>

ptrblck: <p>I think it’s expected to see different results if the spatial input size was changes, as e.g. the conv kernels were trained using a specific resolution.</p>

cbd: <p>In this <a href="https://stackoverflow.com/questions/57349403/different-image-dimensions-during-training-and-testing-time-for-fcns" rel="noopener nofollow ugc">post</a>, it says it can be possible to use different dimension as input but still i confuse. Is the result will be same or different?</p>
<p>If the result is different, is it any trick like changing the trained conv kernels size (repeating value or something else) according to spatial input size during testing?</p>

ptrblck: <p>It’s possible to increase the spatial size if you are using e.g. adaptive pooling layers or make sure to create the expected flattened activation tensor before feeding it into the first linear layer (assuming you are working on a “standard” CNN containing a feature extractor and a classifier).<br>
However, you cannot expect to get the same results.</p>
<p>I don’t know if there are any (well tested) techniques to manipulate the model to achieve a comparable performance using larger inputs. Fine-tuning should work however.</p>

cbd: <aside class="quote no-group" data-username="ptrblck" data-post="4" data-topic="145829">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/48/1823_2.png" class="avatar"> ptrblck:</div>
<blockquote>
<p>or make sure to create the expected flattened activation tensor before feeding it into the first linear layer</p>
</blockquote>
</aside>
<p>You mean to say flatten the input before feeding to first convolution layer? Can you please simplify.</p>
<blockquote>
<p>(assuming you are working on a “standard” CNN containing a feature extractor and a classifier).</p>
</blockquote>
<p>Is it means it can be useful for classification problem not regression where your output is also image?</p>

ptrblck: <aside class="quote no-group" data-username="cbd" data-post="5" data-topic="145829">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/c/13edae/48.png" class="avatar"> cbd:</div>
<blockquote>
<p>You mean to say flatten the input before feeding to first convolution layer? Can you please simplify.</p>
</blockquote>
</aside>
<p>No, I was referring to flattening the activation before feeding it to a linear layer, e.g. as seen in the <a href="https://github.com/pytorch/vision/blob/d8654bb0d84fd2ba8b42cd58d881523821a6214c/torchvision/models/resnet.py#L276-L278">ResNet example</a>.</p>
<aside class="quote no-group" data-username="cbd" data-post="5" data-topic="145829">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/c/13edae/48.png" class="avatar"> cbd:</div>
<blockquote>
<p>Is it means it can be useful for classification problem not regression where your output is also image?</p>
</blockquote>
</aside>
<p>Yes, I think using linear layers at “the end” of the model is commonly used for classification/regression use cases where either class logits or floating point regression values should be created.<br>
If you are trying to create an output image you might want to check model architectures such as e.g. <code>UNet</code>.</p>

cbd: <p>Thanks for clarification.</p>