||
when running at the code of self.criterion(outputs, labels), where I use CrossEntropy as my loss function, I meet the bug of "Dimension out of range (expected to be in range of [-1, 0], but got 1)"
Solution:
From the doc of CrossEntropy (https://pytorch.org/docs/stable/nn.html?highlight=crossentropy#torch.nn.CrossEntropyLoss)
这表明对于loss = self.criterion(output, label)中,output的维度是N*C,而label的维度是N,即label并不是one-hot,CrossEntropy会自动将label转成one-hot
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-9-25 14:37
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社