Answers.Body: <p>I ended up using a work around.</p>
  <p>I set up the network so that an C x C (i.e. 320 x 320) input would output a C x C mask for some constant C (in my case it was 320).</p>
  <p>I then resized the image I wanted to pass in to C x C, and then resized the output back to the original size of the Image.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-29T02:10:06.720Z
Answers.LastActivityDate: 2020-06-29T02:10:06.720Z
Answers.UserDisplayName: Alex
Body: <p>I'm trying to perform a segmentation task on images of multiple sizes using fully convolutional neural networks. </p>
  
  <p>Currently, I'm using EfficientNet as a feature extractor, and adding a deconvolution/backwards convolution/transposed convolution layer as described in the original <a href="https://people.eecs.berkeley.edu/~jonlong/long_shelhamer_fcn.pdf" rel="nofollow noreferrer">Fully Convolutional Networks for Semantic Segmentation</a> paper.</p>
  
  <p>But this transposed convolution layer doesn't return a filter of a size equivalent to the original image for images of varying sizes.</p>
  
  <p>For example, let's assume the original image is <span class="math-container">$100 \times 100$</span>, and the last layer contains filters of size <span class="math-container">$50 \times 50$</span>. To get a filter of the same size as the original, you would need a transposed convolution layer of size <span class="math-container">$51 \times 51$</span>.</p>
  
  <p>Now, assume you passed in an image of size <span class="math-container">$200 \times 200$</span>. The last layer would contain filters of size <span class="math-container">$100 \times 100$</span>. That same transposed convolutional filter of size <span class="math-container">$51 \times 51$</span> would result in an output of size <span class="math-container">$150 \times 150$</span>.</p>
  
  <p>Is there any way to make it so that a fully convolutional network always returns an image of the same size as the original?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-06-14T11:03:08.130Z
Comments.Text: Have you solved this issue? If yes, how? You may want to write a formal answer below, for reference.
Comments.UserDisplayName: nbro
Tags: <machine-learning><deep-learning><convolutional-neural-networks><computer-vision><fully-convolutional-networks>
Title: Can a fully convolutional network always return an image of the same size as the original?
UserDisplayName: Alex
ThreadText: # Can a fully convolutional network always return an image of the same size as the original?
  
  (Asked by: username_0 on 2020-03-28)
  
  I'm trying to perform a segmentation task on images of multiple sizes using fully convolutional neural networks.
  
  Currently, I'm using EfficientNet as a feature extractor, and adding a deconvolution/backwards convolution/transposed convolution layer as described in the original [Fully Convolutional Networks for Semantic Segmentation](https://people.eecs.berkeley.edu/~jonlong/long_shelhamer_fcn.pdf) paper.
  
  But this transposed convolution layer doesn't return a filter of a size equivalent to the original image for images of varying sizes.
  
  For example, let's assume the original image is $100 \times 100$, and the last layer contains filters of size $50 \times 50$. To get a filter of the same size as the original, you would need a transposed convolution layer of size $51 \times 51$.
  
  Now, assume you passed in an image of size $200 \times 200$. The last layer would contain filters of size $100 \times 100$. That same transposed convolutional filter of size $51 \times 51$ would result in an output of size $150 \times 150$.
  
  Is there any way to make it so that a fully convolutional network always returns an image of the same size as the original?
  
  **Tags:** machine-learning, deep-learning, convolutional-neural-networks, computer-vision, fully-convolutional-networks
  
  > **Comments:**
  > **username_1**: Have you solved this issue? If yes, how? You may want to write a formal answer below, for reference.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2020-06-29. Score: 1
  
  I ended up using a work around.
  
  I set up the network so that an C x C (i.e. 320 x 320) input would output a C x C mask for some constant C (in my case it was 320).
  
  I then resized the image I wanted to pass in to C x C, and then resized the output back to the original size of the Image.
  
  
  ---
  
  