RuntimeError: inconsistent tensor sizes
Opened this issue · 3 comments
Running on the cats and dogs dataset, your repo does not work given the following error
my@my:~/Dropbox/x/CV/pytorch-pruning$ CUDA_VISIBLE_DEVICES=0 python finetune.py --train
PrunningFineTuner
('Train folder size', 25000)
('Test folder size', 25000)
fine_tuner.train()
Epoch: 0
Traceback (most recent call last):
File "finetune.py", line 273, in
fine_tuner.train(epoches = 3)
File "finetune.py", line 164, in train
self.train_epoch(optimizer)
File "finetune.py", line 181, in train_epoch
for batch, label in self.train_data_loader:
File "/home/my/anaconda2/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 212, in next
return self._process_next_batch(batch)
File "/home/my/anaconda2/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 239, in _process_next_batch
raise batch.exc_type(batch.exc_msg)
RuntimeError: Traceback (most recent call last):
File "/home/my/anaconda2/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 41, in _worker_loop
samples = collate_fn([dataset[i] for i in batch_indices])
File "/home/my/anaconda2/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 110, in default_collate
return [default_collate(samples) for samples in transposed]
File "/home/my/anaconda2/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 92, in default_collate
return torch.stack(batch, 0, out=out)
File "/home/my/anaconda2/lib/python2.7/site-packages/torch/functional.py", line 60, in stack
return torch.cat(inputs, dim, out=out)
RuntimeError: inconsistent tensor sizes at /py/conda-bld/pytorch_1493676237139/work/torch/lib/TH/generic/THTensorMath.c:2559
Hi,
Are train_path/test_path defined correctly?
Inside the train directory, there should be two directories: cat and dog. As defined in the Readme.
What is the structure of your training directory?
Yes the train and test directories have cat and dog folders in them. I've followed the README.
Can you please post the exact names of the train/test directories?
Are they with capital letters or without?
I'm seeing that you're using the default params for the train/test, perhaps there is a mismatch.