zijundeng / pytorch-semantic-segmentation

PyTorch for Semantic Segmentation
MIT License
1.73k stars 393 forks source link

Inconsistent Tensor Sizes Error when using batch size > 1 for Pascal VOC #28

Open rohitgajawada opened 6 years ago

rohitgajawada commented 6 years ago

Hi! When I tried running your train code for pascal voc, I get RuntimeError: inconsistent tensor sizes at /pytorch/torch/lib/TH/generic/THTensorMath.c:2709 I'm not able to find out the reason for the error Thank you

rohitgajawada commented 6 years ago

Traceback (most recent call last): File "train.py", line 252, in main() File "train.py", line 105, in main train(train_loader, net, criterion, optimizer, curr_epoch, args, val_loader, visualize) File "train.py", line 113, in train for i, data in enumerate(train_loader): File "/home/rohit.gajawada/.local/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 187, in next return self._process_next_batch(batch) File "/home/rohit.gajawada/.local/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 221, in _process_next_batch raise batch.exc_type(batch.exc_msg) RuntimeError: Traceback (most recent call last): File "/home/rohit.gajawada/.local/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 40, in _worker_loop samples = collate_fn([dataset[i] for i in batch_indices]) File "/home/rohit.gajawada/.local/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 109, in default_collate return [default_collate(samples) for samples in transposed] File "/home/rohit.gajawada/.local/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 91, in default_collate return torch.stack(batch, 0, out=out) File "/home/rohit.gajawada/.local/lib/python2.7/site-packages/torch/functional.py", line 66, in stack return torch.cat(inputs, dim, out=out) RuntimeError: inconsistent tensor sizes at /pytorch/torch/lib/TH/generic/THTensorMath.c:2709

zhijiew commented 6 years ago

@rohitgajawada make sure your pytorch version == 0.2.0

wuyi1983 commented 6 years ago

This also happened to me. My pytorch version is 0.3.0 on Windows 10. How to fix this problem?

ksnzh commented 6 years ago

According to requirements.txt, use pytorch 0.2.

2018-02-09 2:29 GMT+08:00 wuyi1983 notifications@github.com:

This also happened to me. My pytorch version is 0.3.0 on Windows 10. How to fix this problem?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ZijunDeng/pytorch-semantic-segmentation/issues/28#issuecomment-364204999, or mute the thread https://github.com/notifications/unsubscribe-auth/AOMWC7aXq0nK7glyavIL_HIfdV55or1Fks5tSz0RgaJpZM4RVOPn .