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

RuntimeError: inconsistent tensor sizes #2

Closed
alphamupsiomega opened this issue Jun 30, 2017 · 3 comments
Closed

RuntimeError: inconsistent tensor sizes #2

alphamupsiomega opened this issue Jun 30, 2017 · 3 comments

Comments

@alphamupsiomega
Copy link

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

@jacobgil
Copy link
Owner

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?

@alphamupsiomega
Copy link
Author

Yes the train and test directories have cat and dog folders in them. I've followed the README.

@jacobgil
Copy link
Owner

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.

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

1 participant