sail-sg / volo

VOLO: Vision Outlooker for Visual Recognition
Apache License 2.0
929 stars 94 forks source link

AttributeError: 'tuple' object has no attribute 'log_softmax' #33

Open Snailgoo opened 3 years ago

Snailgoo commented 3 years ago

Traceback (most recent call last): File "main.py", line 949, in main() File "main.py", line 652, in main train_metrics = train_one_epoch(epoch, File "main.py", line 784, in train_one_epoch loss = loss_fn(output, target) File "C:\Program Files\Anaconda3\envs\yolov5-v4.0\lib\site-packages\torch\nn\modules\module.py", line 727, in _call_impl result = self.forward(*input, **kwargs) File "C:\Program Files\Anaconda3\envs\yolov5-v4.0\lib\site-packages\torch\nn\modules\loss.py", line 961, in forward return F.cross_entropy(input, target, weight=self.weight, File "C:\Program Files\Anaconda3\envs\yolov5-v4.0\lib\site-packages\torch\nn\functional.py", line 2468, in cross_entropy return nll_loss(log_softmax(input, 1), target, weight, None, ignore_index, None, reduction) File "C:\Program Files\Anaconda3\envs\yolov5-v4.0\lib\site-packages\torch\nn\functional.py", line 1605, in log_softmax ret = input.log_softmax(dim) AttributeError: 'tuple' object has no attribute 'log_softmax'

yanjk3 commented 3 years ago

Do you use token label? If not, maybe you should modify "return_dense=True, mix_token=True" to "return_dense=False, mix_token=False" in https://github.com/sail-sg/volo/blob/068a58399e5a8f7fbb1b348522a96c87148caeef/models/volo.py#L462

Snailgoo commented 3 years ago

Do you use token label? If not, maybe you should modify "return_dense=True, mix_token=True" to "return_dense=False, mix_token=False" in

https://github.com/sail-sg/volo/blob/068a58399e5a8f7fbb1b348522a96c87148caeef/models/volo.py#L462

when i fixed your pointed codes, it appeared this error : File "main.py", line 652, in main train_metrics = train_one_epoch(epoch, File "main.py", line 786, in train_one_epoch loss = loss_fn(output, target) File "C:\Program Files\Anaconda3\envs\yolov5-v4.0\lib\site-packages\torch\nn\modules\module.py", line 727, in _call_impl result = self.forward(*input, **kwargs) File "C:\Program Files\Anaconda3\envs\yolov5-v4.0\lib\site-packages\torch\nn\modules\loss.py", line 961, in forward return F.cross_entropy(input, target, weight=self.weight, File "C:\Program Files\Anaconda3\envs\yolov5-v4.0\lib\site-packages\torch\nn\functional.py", line 2468, in cross_entropy return nll_loss(log_softmax(input, 1), target, weight, None, ignore_index, None, reduction) File "C:\Program Files\Anaconda3\envs\yolov5-v4.0\lib\site-packages\torch\nn\functional.py", line 2264, in nll_loss ret = torch._C._nn.nll_loss(input, target.long(), weight, _Reduction.get_enum(reduction), ignore_index) # target RuntimeError: multi-target not supported at C:/w/b/windows/pytorch/aten/src\THCUNN/generic/ClassNLLCriterion.cu:15 i fixed "loss = loss_fn(output, target)" to "loss = loss_fn(output, target.squeeze())", this error still appears what can i do?