ChenHongruixuan / MambaCD

[IEEE TGRS 2024] ChangeMamba: Remote Sensing Change Detection Based on Spatio-Temporal State Space Model
Apache License 2.0
343 stars 16 forks source link

MambaBDA训练时候报错:IndexError: Dimension out of range (expected to be in range of [-1, 0], but got 1) #27

Closed XiaoBaiHhy closed 2 months ago

XiaoBaiHhy commented 5 months ago

Hello, when I was training mamba-BDA-Tiny, the training results were good, but in the 10500 round of evaluation, I made an error: IndexError: Dimension out of range (expected to be in range of [-1,0], but got 1). I printed the probas.shape correctly afterwards. Is there any way to modify this situation.

11%|█         | 10965/100000 [10:43:56<87:08:49,  3.52s/it] Traceback (most recent call last):   File "/home/wg/MambaCD-master/changedetection/script/train_MambaBDA.py", line 236, in     main()   File "/home/wg/MambaCD-master/changedetection/script/train_MambaBDA.py", line 232, in main     trainer.training()   File "/home/wg/MambaCD-master/changedetection/script/train_MambaBDA.py", line 120, in training     lovasz_loss_clf = L.lovasz_softmax(F.softmax(output_clf, dim=1), labels_clf, ignore=255)   File "/home/wg/MambaCD-master/changedetection/utils_func/lovasz_loss.py", line 167, in lovasz_softmax     loss = lovasz_softmax_flat(*flatten_probas(probas, labels, ignore), classes=classes)   File "/home/wg/MambaCD-master/changedetection/utils_func/lovasz_loss.py", line 181, in lovasz_softmax_flat     C = probas.size(1) IndexError: Dimension out of range (expected to be in range of [-1, 0], but got 1)

ChenHongruixuan commented 5 months ago

Hi,

Thank you so much for your question and your interest to our work. I never encountered such a problem previously.

Could you please check the dimensions of the labels and the range of label values in the dataset you are using?

Best,

XiaoBaiHhy commented 5 months ago

hi, thanks for your reply, this problem seems to be an unexpected error in the position where evaluation is batch size=1, after I re-ran it, it doesn't seem to have this problem anymore, in addition, can you provide the weight of the BDA task? Thank you so much

ChenHongruixuan commented 5 months ago

after I re-ran it, it doesn't seem to have this problem anymore

Glad to hear that!

can you provide the weight of the BDA task

BDA and SCD weights will be released after the paper is accepted.

XiaoBaiHhy commented 5 months ago

thanks~

GOZIHUATANEJO commented 5 months ago

Hello, I'm also experiencing this problem and encountering the same error in a different location every time I run it, have you encountered anything similar?

XiaoBaiHhy commented 5 months ago

Hello, I'm also experiencing this problem and encountering the same error in a different location every time I run it, have you encountered anything similar? I don't have this issue after re-running it again, this issue should be an unexpected error with Batch size =1,https://github.com/ChenHongruixuan/MambaCD/issues/27#issuecomment-2113328034,You can try this method.

mdchuc commented 3 months ago

You can try to increase training size to higher resolution such as 512.

Linzy0227 commented 2 months ago

Hello, when I was training mamba-BDA-Tiny, the training results were good, but in the 10500 round of evaluation, I made an error: IndexError: Dimension out of range (expected to be in range of [-1,0], but got 1). I printed the probas.shape correctly afterwards. Is there any way to modify this situation.

11%|█         | 10965/100000 [10:43:56<87:08:49,  3.52s/it] Traceback (most recent call last):   File "/home/wg/MambaCD-master/changedetection/script/train_MambaBDA.py", line 236, in     main()   File "/home/wg/MambaCD-master/changedetection/script/train_MambaBDA.py", line 232, in main     trainer.training()   File "/home/wg/MambaCD-master/changedetection/script/train_MambaBDA.py", line 120, in training     lovasz_loss_clf = L.lovasz_softmax(F.softmax(output_clf, dim=1), labels_clf, ignore=255)   File "/home/wg/MambaCD-master/changedetection/utils_func/lovasz_loss.py", line 167, in lovasz_softmax     loss = lovasz_softmax_flat(*flatten_probas(probas, labels, ignore), classes=classes)   File "/home/wg/MambaCD-master/changedetection/utils_func/lovasz_loss.py", line 181, in lovasz_softmax_flat     C = probas.size(1) IndexError: Dimension out of range (expected to be in range of [-1, 0], but got 1)

您好,请问您最后是怎么解决的呢?

ChenHongruixuan commented 2 months ago

Hi,

Please try to not use lovasz softmax loss or enlarge the crop size. Or you can pre-crop the xBD dataset and exclude the samples whose label values are all 0.

Best,