-
Notifications
You must be signed in to change notification settings - Fork 34
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
Array size mismatch when calculating cross_entropy2d #1
Comments
To use GTA5 data, the label set has to be mapped to the Cityscapes label set. Since GTA5 has a lot more classes and our target is CityScapes, we care only about the common classes. The data organization documentation provided here should help you: https://github.com/VisionLearningGroup/taskcv-2017-public/tree/master/segmentation We will include details about this in the README soon. |
Actually, I found elements in |
This should not happen if the labels are preprocessed correctly. Refer to this condition here: LSD-seg/code/torchfcn/utils.py Line 55 in e373e89
This condition should ensure that the values of |
Well, things go on unexpectedly. LSD-seg/code/torchfcn/utils.py Lines 54 to 57 in e373e89
BTW, I organized the file structure of dataset according to your code's specification. |
In GTA5, there are some image-label pairs which are not of the same size. Hence this exception might be triggered there. Please use the clean filelist that we have uploaded in this repo ? You can find this in the |
Thanks, but I'm using your
So I use the pytorch compiled from source(the latest version) according to this post. |
Does this error occur with all files ? Can you verify why these errors occur ? If you can give more info from your end, we can help debugging this. |
I guess it is all about the version of pytorch. LSD-seg/code/torchfcn/utils.py Lines 54 to 57 in e373e89
BTW, when trying to train on SYNTHIA dataset, I don't know which directory should be marked as LSD-seg/code/torchfcn/utils.py Lines 35 to 44 in e373e89
|
For the SYNTHIA dataset, the labels need to be mapped to be common with
cityscapes. We will upload the mapped data soon.
…On Wed, Apr 11, 2018 at 9:58 PM, chrisliu54 ***@***.***> wrote:
I guess it is all about the *version of* pytorch.
When I used 0.3.1, cross_entropy2d worked fine but backward() met an
RuntimeError said above.
When I used the latest pytorch compiled from source, backward() got right
but cross_entropy2d failed in the try-except block below:
https://github.com/swamiviv/LSD-seg/blob/e373e896be2de7b8c4a0bfa2a7ab0e
fc924836fd/code/torchfcn/utils.py#L54-L57
BTW, when trying to train on SYNTHIA dataset, I don't know which directory
should be marked as synthia_mapped_to_cityscapes specified in
LSD-seg/data/filelist/SYNTHIA_labellist_train.txt. Since
SYNTHIA-RAND-CITYSCAPES datasets contains only three subdirectory, namely,
Depth, GT and RGB(which you choosed to be training images). After check
with the images themselves, I picked GT/COLOR as
synthia_mapped_to_cityscapes(labels). Then I run the code in sourceonly
mode, I then got *RuntimeError* due to array size mismatch in
cross_entropy2d(), specifically, target(that is, labeled image) has shape
of (minibatch x h x w x 4), not (minibatch x h x w).
https://github.com/swamiviv/LSD-seg/blob/e373e896be2de7b8c4a0bfa2a7ab0e
fc924836fd/code/torchfcn/utils.py#L35-L44
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#1 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AGWIeDZ8Lkn_4udQbojMqqlmmOPrsI9Mks5tnrTVgaJpZM4TPdak>
.
--
--Swami
|
@swamiviv Do you upload the mapped data? |
Got a problem with the cross_entropy_2d function as well. Training is running well until it breakes at different points. Sometimes it stops after 350 iterations, sometimes after 2000. Turned off shuffling of the filelists so there should be no issue with the input data. Images and labels are fine. The error which occurs:
Maybe there is a issue due to versions of the installed packages. Until i used the exact version of pytorch you used (0.2.0_3) there were much more issues, so i guess it is important to use exactly your used build @swamiviv . So maybe you could post your versions you used for fcn and opencv packages as well? Due to the not deterministic behaviour of the training i dont know what to do to get this running. :( The only change i made was in segmentation_datasets.py to modify cityscapes labels, which i use as source domain. When i used stock code i got the same Exception mentioned above in the cross_entropy_2d function:
Because of this i flagged all labels, which are out of range (255), with -1, because with 255 we would have more than n_classes. Due to that i changed the code in
Edit/Update |
@Toxiiin may I ask what your workaround involved? I am facing the same issue with
|
@mattmcc97 The easiest solution as a workaround would be to ensure, that the cropped images not only consists out of stuff which is flagged as dont care (-1). A possibility would be to loop over the cropping operation until you get an image which has a proper amount of valid labels (!= -1). Furthermore you could set the calculated loss |
Thanks, I originally thought I might have a mask with everything labelled not interesting. It turns out, there was some corruption in my masks, and a few pixels were labeled with random unexpected values. |
This happens when executing
nll_loss
located incode/torchfcn/utils.py
under the mode ofsourceonly
. The training data is from GTA5.The error occurs because the snippet inside the
cross_entropy2d()
first use a mask to exclude elements whose values are less than 0 intarget
(that is, labels). In other words, mislabeled pixels are not involved when calculating cross entropy.However, the corresponding prediction values for those removed pixels still exist in
log_p
, which leads to the array size conflict.The text was updated successfully, but these errors were encountered: