RuntimeError: Given groups=1, weight of size 16 3 1 1, expected input[3, 1, 128, 128] to have 3 channels, but got 1 channels instead
See original GitHub issue(Originally included this in my other issue, but figured it would make more sense to give it its own issue.)
It seems like training on smaller images still doesn’t work? I just ran this:
sudo docker run --gpus all --rm -it anibali/pytorch:cuda-10.1 bash
sudo curl https://raw.githubusercontent.com/myleott/mnist_png/master/mnist_png.tar.gz > mnist_png.tar.gz
tar -xvzf mnist_png.tar.gz
pip install stylegan2_pytorch
stylegan2_pytorch --data ./mnist_png
and got this:
0%| | 0/100000 [00:00<?, ?it/s]
Traceback (most recent call last):
File "/home/user/miniconda/envs/py36/bin/stylegan2_pytorch", line 55, in <module>
fire.Fire(train_from_folder)
File "/home/user/miniconda/envs/py36/lib/python3.6/site-packages/fire/core.py", line 138, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name)
File "/home/user/miniconda/envs/py36/lib/python3.6/site-packages/fire/core.py", line 471, in _Fire
target=component.__name__)
File "/home/user/miniconda/envs/py36/lib/python3.6/site-packages/fire/core.py", line 675, in _CallAndUpdateTrace
component = fn(*varargs, **kwargs)
File "/home/user/miniconda/envs/py36/bin/stylegan2_pytorch", line 50, in train_from_folder
model.train()
File "/home/user/miniconda/envs/py36/lib/python3.6/site-packages/stylegan2_pytorch/stylegan2_pytorch.py", line 452, in train
real_output = self.GAN.D(image_batch)
File "/home/user/miniconda/envs/py36/lib/python3.6/site-packages/torch/nn/modules/module.py", line 532, in __call__
result = self.forward(*input, **kwargs)
File "/home/user/miniconda/envs/py36/lib/python3.6/site-packages/stylegan2_pytorch/stylegan2_pytorch.py", line 331, in forward
x = self.blocks(x)
File "/home/user/miniconda/envs/py36/lib/python3.6/site-packages/torch/nn/modules/module.py", line 532, in __call__
result = self.forward(*input, **kwargs)
File "/home/user/miniconda/envs/py36/lib/python3.6/site-packages/torch/nn/modules/container.py", line 100, in forward
input = module(input)
File "/home/user/miniconda/envs/py36/lib/python3.6/site-packages/torch/nn/modules/module.py", line 532, in __call__
result = self.forward(*input, **kwargs)
File "/home/user/miniconda/envs/py36/lib/python3.6/site-packages/stylegan2_pytorch/stylegan2_pytorch.py", line 261, in forward
res = self.conv_res(x)
File "/home/user/miniconda/envs/py36/lib/python3.6/site-packages/torch/nn/modules/module.py", line 532, in __call__
result = self.forward(*input, **kwargs)
File "/home/user/miniconda/envs/py36/lib/python3.6/site-packages/torch/nn/modules/conv.py", line 345, in forward
return self.conv2d_forward(input, self.weight)
File "/home/user/miniconda/envs/py36/lib/python3.6/site-packages/torch/nn/modules/conv.py", line 342, in conv2d_forward
self.padding, self.dilation, self.groups)
RuntimeError: Given groups=1, weight of size 16 3 1 1, expected input[3, 1, 128, 128] to have 3 channels, but got 1 channels instead
I also tested this on 72x72 pngs from here: https://github.com/twitter/twemoji/tree/master/assets/72x72 and got the same error message.
Thanks!
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Given groups=1, weight[64, 3, 3, 3], so expected input[16, 64 ...
My input does have 3 channels. The input to the Unet is 3, 1 which corresponds to 3 channels and 1 class.
Read more >RuntimeError: Given groups=1, weight of size [32, 3, 16, 16 ...
The first convolution expects 3 channels, but with your input having size [100, 16, 16, 16, 3], that would be 16 channels.
Read more >RuntimeError: Given groups=1, weight of size 16 6 5 5 ...
RuntimeError : Given groups=1, weight of size 16 6 5 5, expected input[6, 16, 2, 2] to have 6 channels, but got 16...
Read more >Network architectures — MONAI 1.1.0 Documentation
When dropout_dim = 1, randomly zeroes some of the elements for each channel. When dropout_dim = 2, Randomly zeroes out entire channels (a...
Read more >RuntimeError: Given groups=1, weight of size [64, 1, 3, 3 ...
RuntimeError : Given groups=1, weight of size [64, 1, 3, 3], expected input[30, 3, 160, 600] to have 1 channels, but got 3...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@josephrocca this is very helpful actually! it is my goal to let everyone experience this phenomenon easily 😃
All working fine now! Thanks again for this! 😃