xq141839 / DCSAU-Net

Elsevier-CIBM-2023: A deeper and more compact split-attention U-Net for medical image segmentation
https://www.sciencedirect.com/science/article/pii/S0010482523000914
Apache License 2.0
72 stars 16 forks source link

RuntimeError: The size of tensor a (256) must match the size of tensor b (3) at non-singleton dimension 4 #4

Closed WangZhi-wz closed 2 years ago

WangZhi-wz commented 2 years ago

请问我该如何解决这个问题,我使用的是Kavisr数据集,代码没有任何改动,但是出现了这个错误 Epoch 0/149

Traceback (most recent call last): File "D:\paperin\a_new_road\DCSAU-Net-main\train.py", line 176, in model_ft, Loss_list, Accuracy_list = train_model(model_ft, criterion, optimizer_ft, exp_lr_scheduler, File "D:\paperin\a_new_road\DCSAU-Net-main\train.py", line 85, in train_model loss = criterion(outputs, labels) File "D:\ProgramData\Anaconda3\envs\pytorch\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl return forward_call(*input, *kwargs) File "D:\paperin\a_new_road\DCSAU-Net-main\loss.py", line 65, in forward intersection = (inputs targets).sum()
RuntimeError: The size of tensor a (256) must match the size of tensor b (3) at non-singleton dimension 4

这个地方调试的inputs是Tensor(8, 1, 256, 256),但是targets是Tensor(8, 1, 256, 256, 3),请问是需要修改什么还是我数据集划分的问题 数据集划分 ├── data ├── images ├── cju0qkwl35piu0993l0dewei2.png ....... ├── masks ├── cju0qkwl35piu0993l0dewei2_segmentation.png .......

xq141839 commented 2 years ago

那个mask和mask的图片名应该是相同的,这样才能对应起来,可能你需要把_segmentation那部分去掉,有问题可以加我企鹅,GitHub可能回复不及时,抱歉

xq141839 commented 2 years ago

模型那问题你可以给我个邮箱我发你或者加我企鹅我给你