meteorshowers / RCF-pytorch

Richer Convolutional Features for Edge Detection model in pytorch CVPR2017
516 stars 145 forks source link

Some question about batch_size #13

Open weixia1 opened 5 years ago

weixia1 commented 5 years ago

thank you for your code. I found the batch_size = 1 in most edge detection code, also in RCF-pytorch, so is it must to set the batch_size = 1, not batch_size > 1 ?

meteorshowers commented 5 years ago

@weixia1 Hi! It can be bigger than one. I do this just to make this process the same as caffe. You can see the 'itersize' and 'batchsize' param in caffe and will know it.

weixia1 commented 5 years ago

thank you

LoveHRTF commented 5 years ago

But it turns out that if bs > 1 (in this case 16): *** 0.0001 Traceback (most recent call last): File "train_RCF.py", line 350, in <module> main() File "train_RCF.py", line 88, in main assert len(test_list) == len(test_loader), "%d vs %d" % (len(test_list), len(test_loader)) AssertionError: 200 vs 12

Then I hard code the bs for testing set to be 1, using bs=2 in parameter only for training set, got the following error: File "train_RCF.py", line 350, in <module> main() File "train_RCF.py", line 210, in main save_dir = join(TMP_DIR, 'epoch-%d-training-record' % epoch)) File "train_RCF.py", line 237, in train return torch.stack([torch.from_numpy(b) for b in batch], 0) RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0. Got 410 and 375 in dimension 2 at /opt/conda/conda-bld/pytorch_1549635019666/work/aten/src/TH/generic/THTensorMoreMath.cpp:1307

Any solution?