pytorch_misc icon indicating copy to clipboard operation
pytorch_misc copied to clipboard

Sizes of tensors must match except in dimension 1.

Open xysong1201 opened this issue 7 years ago • 0 comments

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-27-8eca1ccc60c7> in <module>
      1 inputs = torch.randn(1, 3, 222, 222).to(device)
      2 print(inputs.dtype)
----> 3 outputs = unet(inputs)
      4 print(outputs.shape)
      5 print(outputs.dtype)

~/miniconda3/envs/deep_mol/lib/python3.6/site-packages/torch/nn/modules/module.py in __call__(self, *input, **kwargs)
    489             result = self._slow_forward(*input, **kwargs)
    490         else:
--> 491             result = self.forward(*input, **kwargs)
    492         for hook in self._forward_hooks.values():
    493             hook_result = hook(self, input, result)

<ipython-input-20-1b02871aaf17> in forward(self, x)
     43         x_up = self.up4(x4, x3)
     44         x_up = self.up3(x_up, x2)
---> 45         x_up = self.up2(x_up, x1)
     46         x_up = self.up1(x_up, x)
     47         x_out = F.log_softmax(self.out(x_up), 1)

~/miniconda3/envs/deep_mol/lib/python3.6/site-packages/torch/nn/modules/module.py in __call__(self, *input, **kwargs)
    489             result = self._slow_forward(*input, **kwargs)
    490         else:
--> 491             result = self.forward(*input, **kwargs)
    492         for hook in self._forward_hooks.values():
    493             hook_result = hook(self, input, result)

<ipython-input-19-4c1c64cb0ec3> in forward(self, x, x_skip)
     15     def forward(self, x, x_skip):
     16         x = self.conv_trans1(x)
---> 17         x = torch.cat((x, x_skip), dim=1)
     18         x = self.conv_block(x)
     19         return x

RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 1. Got 111 and 112 in dimension 2 at /opt/conda/conda-bld/pytorch_1525909934016/work/aten/src/THC/generic/THCTensorMath.cu:111

Hello, I try your code and I encountered this error above. I added the ceil_mode=True but it doesn't work.

xysong1201 avatar Jan 09 '19 09:01 xysong1201