# RuntimeError: Given groups=1, weight of size \[64, 3, 7, 7\], expected input\[3, 1, 224, 224\] to have 3 channels, but got 1 channels instead

**URL:** <https://discuss.pytorch.org/t/runtimeerror-given-groups-1-weight-of-size-64-3-7-7-expected-input-3-1-224-224-to-have-3-channels-but-got-1-channels-instead/30153>\
**Category:** vision\
**Created:** [November 21, 2018, 6:33am UTC](https://discuss.pytorch.org/t/runtimeerror-given-groups-1-weight-of-size-64-3-7-7-expected-input-3-1-224-224-to-have-3-channels-but-got-1-channels-instead/30153 "2018-11-21T06:33:35Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![IAmIronMan](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/iamironman/32/15064_2.png) [@IAmIronMan](https://discuss.pytorch.org/u/IAmIronMan)\
**Post date:** [August 19, 2019, 3:01pm UTC](https://discuss.pytorch.org/t/runtimeerror-given-groups-1-weight-of-size-64-3-7-7-expected-input-3-1-224-224-to-have-3-channels-but-got-1-channels-instead/30153/9 "2019-08-19T15:01:24Z")

</div>

I faced the same problem and alex has explained it properly.

Use this, to convert a [H,W,C] into [C,H,W]  
For including batch\_size(N) use DataLoader, it will automatically include  
image = image.transpose((2, 0, 1))

---

_[View the full topic](https://discuss.pytorch.org/t/runtimeerror-given-groups-1-weight-of-size-64-3-7-7-expected-input-3-1-224-224-to-have-3-channels-but-got-1-channels-instead/30153)._
