Want to add a CNN block in between but getting dimension error

username: Ankit_Jha
cooked: <p><strong>Given groups=1, weight of size 1024 512 1 1, expected input[4, 1024, 8, 16] to have 512 channels, but got 1024 channels instead</strong><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/2X/e/eae35b04bbf4022a7e2644c08a899175264d8e88.png" data-download-href="https://discuss.pytorch.org/uploads/default/eae35b04bbf4022a7e2644c08a899175264d8e88" title="Screenshot%20from%202019-06-04%2010-54-43"><img src="https://discuss.pytorch.org/uploads/default/optimized/2X/e/eae35b04bbf4022a7e2644c08a899175264d8e88_2_690x388.png" alt="Screenshot%20from%202019-06-04%2010-54-43" data-base62-sha1="xvUPM4auOAGg4mjKzHyK7heRzWo" width="690" height="388" srcset="https://discuss.pytorch.org/uploads/default/optimized/2X/e/eae35b04bbf4022a7e2644c08a899175264d8e88_2_690x388.png, https://discuss.pytorch.org/uploads/default/optimized/2X/e/eae35b04bbf4022a7e2644c08a899175264d8e88_2_1035x582.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/2X/e/eae35b04bbf4022a7e2644c08a899175264d8e88_2_1380x776.png 2x" data-dominant-color="E2E6E5"><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">Screenshot%20from%202019-06-04%2010-54-43</span><span class="informations">1920×1080 546 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>
<p>Please let me know where I am doing the mistake.</p>

username: ptrblck
cooked: <p>As the error message explains, your conv layer takes <code>512</code> input channels, while your activation has <code>1024</code>.<br>
You could set <code>in_channels=1024</code> in this particular conv layer to solve this issue.</p>

username: Ankit_Jha
cooked: <p>Thanks <a class="mention" href="/u/ptrblck">@ptrblck</a> , it has been resolved now…</p>

username: Ankit_Jha
cooked: <p>I am facing one more problem… I want to use cross-entropy for semantic segmentation and the dimension of my target [4,3,200,200] and output [4,8,200,200]. giving me an error. 8 represent the number of classes for classification. Because if I am using the same network with output_dim =1 for MSE it is giving me the output. but for semantic, I am getting errors.<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/2X/3/38b0ac5c778e5811661681c0da819a60996da0e9.png" data-download-href="https://discuss.pytorch.org/uploads/default/38b0ac5c778e5811661681c0da819a60996da0e9" title="Screenshot%20from%202019-06-12%2015-59-10"><img src="https://discuss.pytorch.org/uploads/default/optimized/2X/3/38b0ac5c778e5811661681c0da819a60996da0e9_2_690x388.png" alt="Screenshot%20from%202019-06-12%2015-59-10" data-base62-sha1="85vg42fy4j6lwUA2w3ZTqLPuc1r" width="690" height="388" srcset="https://discuss.pytorch.org/uploads/default/optimized/2X/3/38b0ac5c778e5811661681c0da819a60996da0e9_2_690x388.png, https://discuss.pytorch.org/uploads/default/optimized/2X/3/38b0ac5c778e5811661681c0da819a60996da0e9_2_1035x582.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/2X/3/38b0ac5c778e5811661681c0da819a60996da0e9_2_1380x776.png 2x" data-dominant-color="535152"><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">Screenshot%20from%202019-06-12%2015-59-10</span><span class="informations">1920×1080 754 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>

username: Ankit_Jha
cooked: <p>Do I need to convert my masked or labeled image into gray scale and then give color code or directly i can feed my masked RGB image (NYUv2 dataset). Please <a class="mention" href="/u/ptrblck">@ptrblck</a> solve this.</p>

username: ptrblck
cooked: <p>If your target is an RGB image containing the color map, you would have to map it to class indices first.<br>
I’m not familiar with the NYUv2 dataset, but maybe you’ll find some conversion between color codes to class indices.<br>
If you can’t find it, you could create it by yourself using a <code>dict</code>.</p>

username: Ankit_Jha
cooked: <p>ohh I think that is why error is coming!!</p>