RuntimeError: stack expects each tensor to be equal size, but got [3, 375, 500] at entry 0 and [3, 281, 500] at entry 2

rui_zhou: <p>I am running the model (the image all 320*480)using part of voc datasets(different height and width),  the resize part seems not to work, how should I edit it and make it work?<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/7/a/7a2db6ae96b01cbd1819f7708e93b4ef5530c95b.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/7a2db6ae96b01cbd1819f7708e93b4ef5530c95b" title="5"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/7/a/7a2db6ae96b01cbd1819f7708e93b4ef5530c95b_2_690x216.jpeg" alt="5" data-base62-sha1="hqQbVkEA155A3SCpFDzoLGYG2uv" width="690" height="216" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/7/a/7a2db6ae96b01cbd1819f7708e93b4ef5530c95b_2_690x216.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/7/a/7a2db6ae96b01cbd1819f7708e93b4ef5530c95b_2_1035x324.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/7/a/7a2db6ae96b01cbd1819f7708e93b4ef5530c95b.jpeg 2x" data-dominant-color="424242"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">5</span><span class="informations">1301×409 82.5 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div> <div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/2/c/2c308190518b2894df64ddf5accabe9b28a9611a.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/2c308190518b2894df64ddf5accabe9b28a9611a" title="51"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/2/c/2c308190518b2894df64ddf5accabe9b28a9611a_2_654x500.jpeg" alt="51" data-base62-sha1="6iUVOKBm5M2V9n0nN0YPUTdltk6" width="654" height="500" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/2/c/2c308190518b2894df64ddf5accabe9b28a9611a_2_654x500.jpeg, https://discuss.pytorch.org/uploads/default/original/3X/2/c/2c308190518b2894df64ddf5accabe9b28a9611a.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/2/c/2c308190518b2894df64ddf5accabe9b28a9611a.jpeg 2x" data-dominant-color="252525"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">51</span><span class="informations">837×639 55.5 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div> <div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/9/1/910fe5ace736c81fb72842a1af8bdfa615d5e5df.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/910fe5ace736c81fb72842a1af8bdfa615d5e5df" title="52"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/9/1/910fe5ace736c81fb72842a1af8bdfa615d5e5df_2_690x112.jpeg" alt="52" data-base62-sha1="kHhi9j2qnUoT1I4JsBNonniJB71" width="690" height="112" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/9/1/910fe5ace736c81fb72842a1af8bdfa615d5e5df_2_690x112.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/9/1/910fe5ace736c81fb72842a1af8bdfa615d5e5df_2_1035x168.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/9/1/910fe5ace736c81fb72842a1af8bdfa615d5e5df.jpeg 2x" data-dominant-color="878989"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">52</span><span class="informations">1117×182 29.4 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

Henry_Chibueze: <p>Is it possible to post ur entire code coz I don’t think the error is in the block of code u posted<br>
Your resize code works just fine to me</p>
<p>What exactly are u feeding into ur network?<br>
Are u feeding both the mask and image?</p>

anujd9: <p>Hi. I think this error is due to different sized images at input. Make sure to resize the images and the mask to a common size using the <code>Resize()</code> transform before training the model.</p>