RuntimeError: Given groups=1, weight of size 64 2 7 7, expected input[100, 1, 512, 512] to have 2 channels, but got 1 channels instead

Aprilmhx: <p>Hi, everyone. When I ran flownet, got this error, can anyone help me?<br>
This is the place where the error was started, from ‘‘flow_pyramid_pred = [torch.nn.functional.interpolate(model(img_pyramid[-1])[0], size=(256, 256))]’’<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/2X/4/4c2fbbf78b047c3e323aa211509fdfe3839f862e.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/4c2fbbf78b047c3e323aa211509fdfe3839f862e" title="2"><img src="https://discuss.pytorch.org/uploads/default/optimized/2X/4/4c2fbbf78b047c3e323aa211509fdfe3839f862e_2_690x339.jpeg" alt="2" data-base62-sha1="aRYyAAffLN9EYmdkgNzWGiW1jVY" width="690" height="339" srcset="https://discuss.pytorch.org/uploads/default/optimized/2X/4/4c2fbbf78b047c3e323aa211509fdfe3839f862e_2_690x339.jpeg, https://discuss.pytorch.org/uploads/default/optimized/2X/4/4c2fbbf78b047c3e323aa211509fdfe3839f862e_2_1035x508.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/original/2X/4/4c2fbbf78b047c3e323aa211509fdfe3839f862e.jpeg 2x" data-dominant-color="2F2F2F"><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">2</span><span class="informations">1310×644 105 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>And the torch.size of my dataset is [100,1,512,512]</p>

Aprilmhx: <p>And this is the code of flownet-S<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/2X/e/ea43f171b565d9a9dbd812ee960008da9a862401.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/ea43f171b565d9a9dbd812ee960008da9a862401" title="1"><img src="https://discuss.pytorch.org/uploads/default/optimized/2X/e/ea43f171b565d9a9dbd812ee960008da9a862401_2_690x352.jpeg" alt="1" data-base62-sha1="xqpikgjTjINa09GKUQ8AedzuOWd" width="690" height="352" srcset="https://discuss.pytorch.org/uploads/default/optimized/2X/e/ea43f171b565d9a9dbd812ee960008da9a862401_2_690x352.jpeg, https://discuss.pytorch.org/uploads/default/optimized/2X/e/ea43f171b565d9a9dbd812ee960008da9a862401_2_1035x528.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/original/2X/e/ea43f171b565d9a9dbd812ee960008da9a862401.jpeg 2x" data-dominant-color="2E2E2E"><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">1</span><span class="informations">1311×669 132 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>

ptrblck: <p>It seems the default <code>in_channels</code> value is set to 2, while your input data has only a single channel.<br>
Set <code>in_channels=1</code> in your model initialization and run the code again.</p>
<p>PS: It’s always better to post directly by wrapping it in three backticks ``` <img src="https://discuss.pytorch.org/images/emoji/apple/wink.png?v=9" title=":wink:" class="emoji" alt=":wink:"></p>

Aprilmhx: <p>Thanks for your reply!!<br>
but actually i want to input 2 images into flownet, so the in_channel is 2, i really don’t know how could I do it in my code(from [100,1,512,512] to [50,2,512,512]).</p>

ptrblck: <p>If you would like to input two image, would you like to concatenate them in the channel dimension or handle them separately, e.g. by calling the forward method on both images separately?</p>