Skip to content
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

I try to train DANet,but i got these errot ,i have try 1.--aux --se-loss; 2,--aux; 3.--se-loss all error #124

Open
sundongwei opened this issue Dec 5, 2020 · 4 comments

Comments

@sundongwei
Copy link

my env is ubuntu 16, 4xTITAN RTX,
from my temminal:
CUDA_VISIBLE_DEVICES=0,1,2,3 python train.py --dataset citys --model danet --backbone resnet101 --checkname danet101 --base-size 1024 --crop-size 768 --epochs 240 --batch-size 8 --lr 0.003 --workers 2 --multi-grid --multi-dilation 4 8 16 --aux

Traceback (most recent call last):

File "train.py", line 281, in
trainer.training(epoch)
File "train.py", line 213, in training
loss = self.criterion(outputs, target)
File "/home/amax/.conda/envs/th/lib/python3.7/site-packages/torch/nn/modules/module.py", line 532, in call
result = self.forward(input, **kwargs)
File "/home/amax/.conda/envs/th/lib/python3.7/site-packages/torch_encoding-1.2.2b20201205-py3.7.egg/encoding/parallel.py", line 132, in forward
outputs = _criterion_parallel_apply(replicas, inputs, targets, kwargs)
File "/home/amax/.conda/envs/th/lib/python3.7/site-packages/torch_encoding-1.2.2b20201205-py3.7.egg/encoding/parallel.py", line 185, in _criterion_parallel_apply
raise output
File "/home/amax/.conda/envs/th/lib/python3.7/site-packages/torch_encoding-1.2.2b20201205-py3.7.egg/encoding/parallel.py", line 160, in _worker
output = module(
(input + target), **kwargs)
File "/home/amax/.conda/envs/th/lib/python3.7/site-packages/torch/nn/modules/module.py", line 532, in call
result = self.forward(*input, **kwargs)
File "/home/amax/.conda/envs/th/lib/python3.7/site-packages/torch_encoding-1.2.2b20201205-py3.7.egg/encoding/nn/loss.py", line 75, in forward
pred, se_pred, target = tuple(inputs)
ValueError: too many values to unpack (expected 3)

@RainHxj
Copy link

RainHxj commented Dec 6, 2020

From the ReadMe, the code author provides testing code. If you train it, you should check the "loss part" of the code.

you could refer to the "loss part" of tag v0.5.0
https://github.com/junfu1115/DANet/tree/v0.5.0

@sundongwei
Copy link
Author

From the ReadMe, the code author provides testing code. If you train it, you should check the "loss part" of the code.

you could refer to the "loss part" of tag v0.5.0
https://github.com/junfu1115/DANet/tree/v0.5.0

thank you for your rely . I have found this problem, so i changed the loss function like this :
**class SegmentationMultiLosses(nn.CrossEntropyLoss):
"""2D Cross Entropy Loss with Multi-L1oss"""
def init(self, nclass=-1, weight=None,size_average=True, ignore_index=-1):
super(SegmentationMultiLosses, self).init(weight, size_average, ignore_index)
self.nclass = nclass

def forward(self, *inputs):

    *preds, target = tuple(inputs)
    pred1, pred2 ,pred3= tuple(preds)


    loss1 = super(SegmentationMultiLosses, self).forward(pred1, target)
    loss2 = super(SegmentationMultiLosses, self).forward(pred2, target)
    loss3 = super(SegmentationMultiLosses, self).forward(pred3, target)
    loss = loss1 + loss2 + loss3
    return loss**

and i wonder you method "loss part", whether means this class "DANet/encoding/nn/customize.py /SegmentationMultiLosses"

@RainHxj
Copy link

RainHxj commented Dec 6, 2020

yes

@sundongwei
Copy link
Author

yes

thank you ~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants