UNeXt-pytorch icon indicating copy to clipboard operation
UNeXt-pytorch copied to clipboard

deep_supervision

Open long123524 opened this issue 2 years ago • 3 comments

image I want to use deep_supervision, but I find a error, should I how to deal with this error? What the function of the deep_supervision? Thank you!

long123524 avatar Apr 10 '22 08:04 long123524

I finished the training on BUSI without DS, but when I tried to train on BUSI dataset with DS and met the same question, have you solved it? @long123524

Zhu1Li avatar Aug 23 '22 07:08 Zhu1Li

I finished the training on BUSI without DS, but when I tried to train on BUSI dataset with DS and met the same question, have you solved it? @long123524

Hey I got where the problem is, it happens because your "output"(torch.Size([1, 256, 256])) and "target"( torch.Size([8, 1, 256, 256])) is not dimmensional equal so your criterion function cannot calculate the right loss, all you need to do is changing the

for output in outputs:

loss += criterion(output, target)

into

for i in range(len(outputs)):

loss += criterion(outputs[i], target[i])

in both train function(119,120 line) and validate function(166, 167 line) of train.py; then the code with configure "--deep_supervision True" will run correctly.

Zhu1Li avatar Aug 24 '22 00:08 Zhu1Li

I finished the training on BUSI without DS, but when I tried to train on BUSI dataset with DS and met the same question, have you solved it? @long123524

Hey I got where the problem is, it happens because your "output"(torch.Size([1, 256, 256])) and "target"( torch.Size([8, 1, 256, 256])) is not dimmensional equal so your criterion function cannot calculate the right loss, all you need to do is changing the

for output in outputs:

loss += criterion(output, target)

into

for i in range(len(outputs)):

loss += criterion(outputs[i], target[i])

in both train function(119,120 line) and validate function(166, 167 line) of train.py; then the code with configure "--deep_supervision True" will run correctly.

Found something wrong with code, I used same configures but got a very terrible IoU score on BUSI dataset with deep supervision than without, and I compared the code of UNeXt and UNet++, found that archs.py of UNeXt which defines the network architecture considers nothing about deep supervision(just one stage to output), while the losses.py and the part of train&vaildate function about deep supervision in train.py is totally the same as UNet++'s code. So I guess that the author did not consider using deep supervision in the network, but just modified the code framework against UNet++ without removing the deep supervision part.

Zhu1Li avatar Aug 26 '22 06:08 Zhu1Li

Yes, deep supervision part was not used in UNeXt training.

jeya-maria-jose avatar Dec 21 '22 21:12 jeya-maria-jose

I finished the training on BUSI without DS, but when I tried to train on BUSI dataset with DS and met the same question, have you solved it? @long123524

Hey I got where the problem is, it happens because your "output"(torch.Size([1, 256, 256])) and "target"( torch.Size([8, 1, 256, 256])) is not dimmensional equal so your criterion function cannot calculate the right loss, all you need to do is changing the

for output in outputs:

loss += criterion(output, target)

into

for i in range(len(outputs)):

loss += criterion(outputs[i], target[i])

in both train function(119,120 line) and validate function(166, 167 line) of train.py; then the code with configure "--deep_supervision True" will run correctly.

Good job

Alan-Py avatar Apr 21 '23 17:04 Alan-Py