Alibaba-MIIL / ASL

Official Pytorch Implementation of: "Asymmetric Loss For Multi-Label Classification"(ICCV, 2021) paper
MIT License
732 stars 102 forks source link

This problem occurs when I use the ASLSingleLabel. #64

Closed JonasZero closed 3 years ago

JonasZero commented 3 years ago

RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [64, 38]] is at version 3; expected version 1 instead. Hint: the backtrace further above shows the operation that failed to compute its gradient. The variable in question was changed in there or anywhere later. Good luck!

I use a single label classification dataset. The version of Pytorch I use is 1.7.1.

mrT23 commented 3 years ago

try different loss. i don't think this is related to ASL. if different loss does work, give reproducible code

wangsssky commented 3 years ago

RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [64, 38]] is at version 3; expected version 1 instead. Hint: the backtrace further above shows the operation that failed to compute its gradient. The variable in question was changed in there or anywhere later. Good luck!

I use a single label classification dataset. The version of Pytorch I use is 1.7.1.

targets = copy.deepcopy(self.targets_classes) The code above solve this.

mrT23 commented 3 years ago

provide full reproduction code

Qidian213 commented 3 years ago

For me, the CrossEntropyLoss can work well, but when I change to use ASLSingleLabel it occurs same error. And targets = copy.deepcopy(self.targets_classes) work for me.

mrT23 commented 3 years ago

i fixed the issue (it occurs on some models, on others it does not).

not recommended to do: targets = copy.deepcopy(self.targets_classes) which will cause you GPU memory leak along long training