Input dimension error

username: Angry_potato
cooked: <p>Hi i am getting the following error when i try to implement a classifier<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/0/8/085e63ed90e00cf53f7d7811ded8e04e3b0012c6.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/085e63ed90e00cf53f7d7811ded8e04e3b0012c6" title="IMG_20200327_150058"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/0/8/085e63ed90e00cf53f7d7811ded8e04e3b0012c6_2_666x500.jpeg" alt="IMG_20200327_150058" data-base62-sha1="1c236KjWR65H3cdFglcd5dnCsRw" width="666" height="500" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/0/8/085e63ed90e00cf53f7d7811ded8e04e3b0012c6_2_666x500.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/0/8/085e63ed90e00cf53f7d7811ded8e04e3b0012c6_2_999x750.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/0/8/085e63ed90e00cf53f7d7811ded8e04e3b0012c6_2_1332x1000.jpeg 2x" data-dominant-color="7A7973"><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">IMG_20200327_150058</span><span class="informations">2080×1560 1.23 MB</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/b/e/be0fe8fb4f568d5dd01e568786526f391328d500.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/be0fe8fb4f568d5dd01e568786526f391328d500" title="IMG_20200327_150107"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/b/e/be0fe8fb4f568d5dd01e568786526f391328d500_2_666x500.jpeg" alt="IMG_20200327_150107" data-base62-sha1="r7mO0vGjeDINgxczZbs8wyUbsaY" width="666" height="500" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/b/e/be0fe8fb4f568d5dd01e568786526f391328d500_2_666x500.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/b/e/be0fe8fb4f568d5dd01e568786526f391328d500_2_999x750.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/b/e/be0fe8fb4f568d5dd01e568786526f391328d500_2_1332x1000.jpeg 2x" data-dominant-color="737068"><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">IMG_20200327_150107</span><span class="informations">2080×1560 1.15 MB</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>
I am unable to understand why this is happening</p>

username: justusschock
cooked: <p>The input of a 2D Cons has to have 4 dimensions: NxCxHxW where N is the Batchsize, C is the Channel Size and H and W are the spatial image sizes.</p>
<p>From your screenshot it seems, that your input is of size (28, 28, 1) which is most likely (H, W, C). So at first you have to move the channel dimension to the front and then add another dimension to be the batch dim.</p>

username: Angry_potato
cooked: <p>Thank you very much<br>
Can you tell me the syntax of conv2d as the syntax is unclear from the discription</p>

username: justusschock
cooked: <p>I don’t know, what you mean by syntax.</p>
<p>So your reshape would probably be <code>np.reshape(x, (1, 1, 28, 28))</code> if that’s what you were asking for.</p>

username: Angry_potato
cooked: <p>Oh i got that part.<br>
Thank you very much for the help</p>