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

train pspnet error #49

Open
lfdeep opened this issue Nov 28, 2018 · 5 comments
Open

train pspnet error #49

lfdeep opened this issue Nov 28, 2018 · 5 comments

Comments

@lfdeep
Copy link

lfdeep commented Nov 28, 2018

When I train pspnet, set batch=2, it appears:
[epoch 1], [iter 10 / 4249], [train main loss 1.44544], [train aux loss 2.11281]. [lr 0.0049986500]
[epoch 1], [iter 20 / 4249], [train main loss 1.35266], [train aux loss 1.68135]. [lr 0.0049971499]
Traceback (most recent call last):
File "./train/voc-psp_net/train.py", line 258, in
main()
File "./train/voc-psp_net/train.py", line 111, in main
train(train_loader, net, criterion, optimizer, curr_epoch, args, val_loader, visualize)
File "./train/voc-psp_net/train.py", line 119, in train
for i, data in enumerate(train_loader):
File "/share/home/math8/.conda/envs/pytorch0.4.0_py3.5/lib/python3.5/site-packages/torch/utils/data/dataloader.py", line 286, in next
return self._process_next_batch(batch)
File "/share/home/math8/.conda/envs/pytorch0.4.0_py3.5/lib/python3.5/site-packages/torch/utils/data/dataloader.py", line 307, in _process_next_batch
raise batch.exc_type(batch.exc_msg)
RuntimeError: Traceback (most recent call last):
File "/share/home/math8/.conda/envs/pytorch0.4.0_py3.5/lib/python3.5/site-packages/torch/utils/data/dataloader.py", line 57, in _worker_loop
samples = collate_fn([dataset[i] for i in batch_indices])
File "/share/home/math8/.conda/envs/pytorch0.4.0_py3.5/lib/python3.5/site-packages/torch/utils/data/dataloader.py", line 138, in default_collate
return [default_collate(samples) for samples in transposed]
File "/share/home/math8/.conda/envs/pytorch0.4.0_py3.5/lib/python3.5/site-packages/torch/utils/data/dataloader.py", line 138, in
return [default_collate(samples) for samples in transposed]
File "/share/home/math8/.conda/envs/pytorch0.4.0_py3.5/lib/python3.5/site-packages/torch/utils/data/dataloader.py", line 115, in default_collate
return torch.stack(batch, 0, out=out)
RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0. Got 4 and 2 in dimension 1 at /opt/conda/conda-bld/pytorch_1524580978845/work/aten/src/TH/generic/THTensorMath.c:3586

i don't know how to solve it?

@wxy920801
Copy link

I meet this problem too

@lfdeep
Copy link
Author

lfdeep commented Dec 5, 2018

I meet this problem too

I have solved this problem.You should set train_batch_size>=2

@wxy920801
Copy link

I meet this problem too

I have solved this problem.You should set train_batch_size>=2

Thank you. I tried to set train_batch_size=4 or 6, while this didn't work. Maybe anything else to correct?

@lfdeep
Copy link
Author

lfdeep commented Dec 6, 2018

I meet this problem too

I have solved this problem.You should set train_batch_size>=2

Thank you. I tried to set train_batch_size=4 or 6, while this didn't work. Maybe anything else to correct?

You should fix the input large image to the same size.
args = {
'train_batch_size': 4,
'lr': 1e-2 / sqrt(16 / 4),
'lr_decay': 0.9,
'max_iter': 3e4,
#'longer_size': 512,
#'crop_size': 473,
'input_size': 473,
'stride_rate': 2 / 3.,
'weight_decay': 1e-4,
'momentum': 0.9,
'snapshot': '',
'print_freq': 10,
'val_save_to_img_file': True,
'val_img_sample_rate': 0.01, # randomly sample some validation results to display,
'val_img_display_size': 384,
}
train_joint_transform = joint_transforms.Compose([
#joint_transforms.Scale(args['longer_size']),
joint_transforms.Scale(args['input_size']),
joint_transforms.RandomRotate(10),
joint_transforms.RandomHorizontallyFlip()
sliding_crop = joint_transforms.SlidingCrop(args['input_size'], args['stride_rate'], voc.ignore_label)
This is my modified code, I fixed my input image to 473

@wxy920801
Copy link

wow, done!
Thanks!

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

2 participants