Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeError: Given groups=1, weight of size [64, 18, 4, 4], expected input[2, 4, 256, 256] to have 18 channels, but got 4 channels instead #7

Closed
YuanBo66668888 opened this issue Jun 28, 2020 · 6 comments

Comments

@YuanBo66668888
Copy link

YuanBo66668888 commented Jun 28, 2020

we run command
python train.py --name celebahqedge --dataset_mode celebahqedge --dataroot dataset_path --niter 30 --niter_decay 30 --which_perceptual 4_2 --weight_perceptual 0.001 --use_attention --maskmix --PONO --PONO_C --vgg_normal_correct --fm_ratio 1.0 --warp_bilinear --warp_cycle_w 1 --batchSize 1 --gpu_ids 0

but have some errors

/home/dc2-user/.local/lib/python3.7/site-packages/torch/nn/functional.py:1558: UserWarning: nn.functional.tanh is deprecated. Use torch.tanh instead.
warnings.warn("nn.functional.tanh is deprecated. Use torch.tanh instead.")
Traceback (most recent call last):
File "train.py", line 58, in
trainer.run_discriminator_one_step(data_i)
File "/home/dc2-user/tomyuan-workstation/CoCosNet/trainers/pix2pix_trainer.py", line 70, in run_discriminator_one_step
d_losses = self.pix2pix_model(data, mode='discriminator', GforD=GforD)
File "/home/dc2-user/.local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 550, in call
result = self.forward(*input, **kwargs)
File "/home/dc2-user/tomyuan-workstation/CoCosNet/models/pix2pix_model.py", line 75, in forward
input_semantics, real_image, GforD, label=input_label)
File "/home/dc2-user/tomyuan-workstation/CoCosNet/models/pix2pix_model.py", line 289, in compute_discriminator_loss
input_semantics, fake_image, real_image)
File "/home/dc2-user/tomyuan-workstation/CoCosNet/models/pix2pix_model.py", line 352, in discriminate
discriminator_out, seg, cam_logit = self.net'netD'
File "/home/dc2-user/.local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 550, in call
result = self.forward(*input, **kwargs)
File "/home/dc2-user/tomyuan-workstation/CoCosNet/models/networks/discriminator.py", line 62, in forward
out, cam_logit = D(input)
File "/home/dc2-user/.local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 550, in call
result = self.forward(*input, **kwargs)
File "/home/dc2-user/tomyuan-workstation/CoCosNet/models/networks/discriminator.py", line 152, in forward
intermediate_output = submodel(x)
File "/home/dc2-user/.local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 550, in call
result = self.forward(*input, **kwargs)
File "/home/dc2-user/.local/lib/python3.7/site-packages/torch/nn/modules/container.py", line 100, in forward
input = module(input)
File "/home/dc2-user/.local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 550, in call
result = self.forward(*input, **kwargs)
File "/home/dc2-user/.local/lib/python3.7/site-packages/torch/nn/modules/conv.py", line 353, in forward
return self._conv_forward(input, self.weight)
File "/home/dc2-user/.local/lib/python3.7/site-packages/torch/nn/modules/conv.py", line 350, in _conv_forward
self.padding, self.dilation, self.groups)
RuntimeError: Given groups=1, weight of size [64, 18, 4, 4], expected input[2, 4, 256, 256] to have 18 channels, but got 4 channels instead

@panzhang0212
Copy link
Contributor

Duplicate of #3

@panzhang0212 panzhang0212 marked this as a duplicate of #3 Jun 28, 2020
@YuanBo66668888
Copy link
Author

It's effective!!
#3 solved by self.preprocess_input(data, ) to self.preprocess_input(data.copy(), ) in line 52 of pix2pix_model.py!

@YuanBo66668888
Copy link
Author

The another question is we have only one gpu(0) is 16G,the train is very slow,have some method to improve train process, Thanks! I send a email to you! I very glad and hope to received your reply

@panzhang0212
Copy link
Contributor

please check your email.

@YuanBo66668888
Copy link
Author

Thank you very much, I'm working on cost functions,Is it convenient to add you as a friend?

@XiangyuSu611
Copy link

Hi, @YuanBo66668888 I have the same problems with you, training process is very slow. How did you slove this problem? Could you please give me a notice? By the way, I can speak chinese.

Thanks first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants