pytorch-semseg icon indicating copy to clipboard operation
pytorch-semseg copied to clipboard

ValueError: Expected input batch_size to match target batch_size when running fcn8 on Pascal

Open mariaka opened this issue 6 years ago • 4 comments

Hi! I'm trying python train.py with default settings on the Pascal dataset with fcn8. After 1000 iterations I get the following error:

Traceback (most recent call last): File "train.py", line 229, in <module> train(cfg, writer, logger) File "train.py", line 159, in train val_loss = loss_fn(input=outputs, target=labels) File "/pytorch-semseg/ptsemseg/loss/loss.py", line 24, in cross_entropy2d input, target, weight=weight, size_average=size_average, ignore_index=250 File "/anaconda3/lib/python3.6/site-packages/torch/nn/functional.py", line 1550, in cross_entropy return nll_loss(log_softmax(input, 1), target, weight, None, ignore_index, None, reduction) File "/anaconda3/lib/python3.6/site-packages/torch/nn/functional.py", line 1405, in nll_loss .format(input.size(0), target.size(0))) ValueError: Expected input batch_size (183000) to match target batch_size (187500).

What could the problem be?

mariaka avatar Sep 11 '18 15:09 mariaka

It seems that "labels" in line 15 (train.py) needs to be replaced by "labels_val": val_loss = loss_fn(input=outputs, target=labels_val)

siavashBigdeli avatar Sep 12 '18 12:09 siavashBigdeli

hello i'm facing the same issue. did you find any solution ?

image

shariq-ali avatar Nov 29 '19 10:11 shariq-ali

I'm facing the same issue. Did you find any solution?

Huskywyh avatar Mar 18 '24 14:03 Huskywyh

我已收到,谢谢

hjhjb avatar Mar 18 '24 14:03 hjhjb