FengheTan9 / Medical-Image-Segmentation-Benchmarks

A Pytorch implement of medical image segmentation U-shape architecture benchmarks
MIT License
74 stars 3 forks source link

RuntimeError Discussion #7

Closed NUS-Tim closed 6 months ago

NUS-Tim commented 6 months ago

I'm encountering a RuntimeError regarding the "SwinUnet" as below.

Traceback (most recent call last):
  File "C:\Users\e0575844\Desktop\SBM V2\train.py", line 195, in <module>
    main(args)
  File "C:\Users\e0575844\Desktop\SBM V2\train.py", line 144, in main
    loss = criterion(outputs, label_batch)
  File "C:\Users\e0575844\Anaconda3\envs\MedAugment\lib\site-packages\torch\nn\modules\module.py", line 1194, in _call_impl
    return forward_call(*input, **kwargs)
  File "C:\Users\e0575844\Desktop\SBM V2\src\utils\losses.py", line 18, in forward
    input = input.view(num, -1)
RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.

As replacing the view can affect the remaining approaches, I'm searching for any solution to handle the model itself rather than the loss pipeline. Thx.

FengheTan9 commented 6 months ago

you can refer this issues