Predicted output image is split

jun_suk_ha: <p>Hi,<br>
I understand that my question is too ambiguous but I couldn’t help. I’m working on  3d reconstruction. Basically, I have latent codes. I train two models: a model that generates my latent code which represents a 3d scene, and a model that renders the image out of latent code.</p>
<p>But my output image is split in two. Can you guess why or when would this happen? I wanted to post my code but as I don’t know which part is wrong and the code is super long, I thought it would be better to ask for some guesses and figure out myself what is causing the issue.<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/7/4/74bcef872be6c05073ba1d81f8b8e0a9f16a3d0e.png" data-download-href="https://discuss.pytorch.org/uploads/default/74bcef872be6c05073ba1d81f8b8e0a9f16a3d0e" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/7/4/74bcef872be6c05073ba1d81f8b8e0a9f16a3d0e_2_690x215.png" alt="image" data-base62-sha1="gEIb7pQEFjUuX6mlr621PhvH8dg" width="690" height="215" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/7/4/74bcef872be6c05073ba1d81f8b8e0a9f16a3d0e_2_690x215.png, https://discuss.pytorch.org/uploads/default/optimized/3X/7/4/74bcef872be6c05073ba1d81f8b8e0a9f16a3d0e_2_1035x322.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/7/4/74bcef872be6c05073ba1d81f8b8e0a9f16a3d0e.png 2x" data-dominant-color="C4A0A0"><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">image</span><span class="informations">1318×411 45.9 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><br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/3/7/37bc9cc2dce65fee5e0ccf2d61260625a0df0739.png" data-download-href="https://discuss.pytorch.org/uploads/default/37bc9cc2dce65fee5e0ccf2d61260625a0df0739" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/3/7/37bc9cc2dce65fee5e0ccf2d61260625a0df0739_2_690x220.png" alt="image" data-base62-sha1="7X4mnyDvAN4AemfuNvZS0bcIcRP" width="690" height="220" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/3/7/37bc9cc2dce65fee5e0ccf2d61260625a0df0739_2_690x220.png, https://discuss.pytorch.org/uploads/default/optimized/3X/3/7/37bc9cc2dce65fee5e0ccf2d61260625a0df0739_2_1035x330.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/3/7/37bc9cc2dce65fee5e0ccf2d61260625a0df0739.png 2x" data-dominant-color="C5ABAB"><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">image</span><span class="informations">1284×411 48.8 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>
<h2><a name="edit-1" class="anchor" href="#edit-1"></a>EDIT</h2>
<p>OMG. Unbelievably, I somehow fixed it. lol</p>
<p>values.shape = [4, 128, 1, 1, 409600]<br>
feature_size = 128<br>
bs (batch_size) = 4</p>
<p>I need to make [bs, -1, feature_size]</p>
<p>before:<br>
values = values.squeeze().reshape(bs, -1, feature_size)</p>
<p>after:<br>
values = values.squeeze().permute(0, 2, 1)</p>
<p>I think the before version was causing that issue. I thought those two versions work the same?</p>

nwn: <p>Hello <a class="mention" href="/u/jun_suk_ha">@jun_suk_ha</a> ,<br>
unfortunately, I can not say, why your images looked like the ones above. But, I can say, that there is a difference between permute and reshape, although they can generate the same shaped tensors. For visualization, I have created a small example below. Note that I have deleted the “[1,1]” part, because it is taken out by the .squeeze() command:</p>
<p>n_features = 6<br>
batch_size = 2<br>
misc = 100<br>
a = torch.randn( batch_size, n_features, misc)<br>
b = a.reshape(batch_size, -1, n_features)<br>
c = a.permute(0,2,1)<br>
print(torch.allclose(b,c)) # → False<br>
print(b.shape == c.shape) # → True</p>
<p>Best,<br>
nwn</p>