RuntimeError: The size of tensor a (10) must match the size of tensor b (3) at non-singleton dimension 1

showbit: <p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/4/6/462283fcd4fe04b9aeb9fb8800ead48478b3bbe7.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/462283fcd4fe04b9aeb9fb8800ead48478b3bbe7" title="Screenshot 2021-05-15 at 2.19.39 AM"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/4/6/462283fcd4fe04b9aeb9fb8800ead48478b3bbe7_2_690x431.jpeg" alt="Screenshot 2021-05-15 at 2.19.39 AM" data-base62-sha1="a0rn4MRVOiFIAFH2T4wtSipM0JN" width="690" height="431" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/4/6/462283fcd4fe04b9aeb9fb8800ead48478b3bbe7_2_690x431.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/4/6/462283fcd4fe04b9aeb9fb8800ead48478b3bbe7_2_1035x646.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/4/6/462283fcd4fe04b9aeb9fb8800ead48478b3bbe7_2_1380x862.jpeg 2x" data-dominant-color="434547"><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 2021-05-15 at 2.19.39 AM</span><span class="informations">1440×900 216 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>Here is my model:</p>
<p>&lt;bound method Module.state_dict of model(<br>
(hidden_layers): ModuleList(<br>
(0): Linear(in_features=3, out_features=10, bias=True)<br>
(1): Linear(in_features=10, out_features=10, bias=True)<br>
)<br>
(output_layers): ModuleList(<br>
(0): Linear(in_features=10, out_features=4, bias=True)<br>
(1): Linear(in_features=10, out_features=4, bias=True)<br>
)<br>
)&gt;</p>

pascal_notsawo: <p>I think your model input has a wrong dimension: the model expects 3 (…x3), but you give it 10 (…x10)…As the message says</p>
<p>More details about this would be useful to help you</p>

showbit: <p>Thanks for reply,<br>
when first example of 1*3 is passed through first hidden layer it works,<br>
below is weight matrix 3 * 10 of first hidden layer:<br>
(Pytorch output):<br>
tensor([[ 0.4778,  0.4947, -0.4435],<br>
[-0.0535,  0.5000,  0.1650],<br>
[-0.5120,  0.5192, -0.0072],<br>
[-0.1666,  0.0537,  0.5399],<br>
[-0.5655, -0.4967,  0.0043],<br>
[ 0.1430,  0.0842, -0.4497],<br>
[-0.1533,  0.2130, -0.4762],<br>
[-0.2144, -0.3397, -0.1646],<br>
[-0.1230, -0.3268,  0.4827],<br>
[-0.4620, -0.3071,  0.3321]], dtype=torch.float64)</p>
<p>when second example of same batch is passed then it throws error of size mismatching.Below is the weight matrix of first hidden layer after updating</p>
<p>tensor([[-1.9652e-05, -5.2278e-04,  5.1098e-05],<br>
[ 6.4976e-06,  1.7285e-04, -1.6894e-05],<br>
[ 3.9244e-06,  1.0440e-04, -1.0204e-05],<br>
[-9.4330e-06, -2.5093e-04,  2.4527e-05],<br>
[ 8.6443e-06,  2.2995e-04, -2.2476e-05],<br>
[ 4.9573e-06,  1.3187e-04, -1.2889e-05],<br>
[-9.0200e-07, -2.3995e-05,  2.3453e-06],<br>
[-9.8638e-06, -2.6239e-04,  2.5647e-05],<br>
[ 8.2014e-06,  2.1817e-04, -2.1324e-05],<br>
[-8.1189e-06, -2.1598e-04,  2.1110e-05]], dtype=torch.float64)</p>
<p>Dimensions are same for the second example also how could it be possible ??</p>