Paper-Implementations icon indicating copy to clipboard operation
Paper-Implementations copied to clipboard

Error in running the cyclegan code

Open soumyadeepg opened this issue 7 years ago • 1 comments

In the cycle gan code i am getting the following error while training the model

File "CycleGAN.py", line 211, in outA = D_A(real_A) File "/home/iab/anaconda2/envs/pytorch/lib/python2.7/site-packages/torch/nn/modules/module.py", line 224, in call result = self.forward(*input, **kwargs) File "/media/iab/New Volume/soumyadeep/Paper-Implementations-master/cycleGAN/model/Discriminator.py", line 57, in forward out = self.layer2(out) File "/home/iab/anaconda2/envs/pytorch/lib/python2.7/site-packages/torch/nn/modules/module.py", line 224, in call result = self.forward(*input, **kwargs) File "/home/iab/anaconda2/envs/pytorch/lib/python2.7/site-packages/torch/nn/modules/container.py", line 67, in forward input = module(input) File "/home/iab/anaconda2/envs/pytorch/lib/python2.7/site-packages/torch/nn/modules/module.py", line 224, in call result = self.forward(*input, **kwargs) File "/media/iab/New Volume/soumyadeep/Paper-Implementations-master/cycleGAN/model/Discriminator.py", line 25, in forward mean = torch.mean(t, 2).unsqueeze(2).expand_as(x) File "/home/iab/anaconda2/envs/pytorch/lib/python2.7/site-packages/torch/autograd/variable.py", line 725, in expand_as return Expand.apply(self, (tensor.size(),)) File "/home/iab/anaconda2/envs/pytorch/lib/python2.7/site-packages/torch/autograd/_functions/tensor.py", line 111, in forward result = i.expand(*new_size) RuntimeError: The expanded size of the tensor (32) must match the existing size (128) at non-singleton dimension 2. at /opt/conda/conda-bld/pytorch_1503966894950/work/torch/lib/THC/generic/THCTensor.c:323

PLEASE HELP !!

soumyadeepg avatar Dec 19 '17 15:12 soumyadeepg

Because the mean function has decrease the dimension of the tensor and the default setting for the parameter 'keepdim ' in pytorch 0.4 is False. The code should be re-written as torch.mean(input, dim, keepdim=True)

MapleSpirit avatar Jun 20 '18 04:06 MapleSpirit