pochih / FCN-pytorch

🚘 Easiest Fully Convolutional Networks
404 stars 143 forks source link

ValueError: Target size (torch.Size([2, 32, 480, 640])) must be the same as input size (torch.Size([2, 20, 480, 640])) #15

Closed Hyakuju closed 5 years ago

Hyakuju commented 5 years ago

Hello, i tried to train the fcn on my own computer, and i set the batch to 2. Everything went well but i got this traceback error.

Traceback (most recent call last): File "train.py", line 171, in train() File "train.py", line 101, in train loss = criterion(outputs, labels) File "C:\Users\83750\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 489, in call result = self.forward(*input, **kwargs) File "C:\Users\83750\Anaconda3\lib\site-packages\torch\nn\modules\loss.py", line 595, in forward reduction=self.reduction) File "C:\Users\83750\Anaconda3\lib\site-packages\torch\nn\functional.py", line 2075, in binary_cross_entropy_with_logits raise ValueError("Target size ({}) must be the same as input size ({})".format(target.size(), input.size())) ValueError: Target size (torch.Size([2, 32, 480, 640])) must be the same as input size (torch.Size([2, 20, 480, 640]))

how could this happen? how can i solve it? i'll be appreciated if you could help me.

LuDCD commented 5 years ago

how to solve?

Hyakuju commented 5 years ago

just change your num_class to correct one.