“nll_loss_forward_reduce_cuda_kernel_2d_index“ not implemented for ‘Float‘
Traceback (most recent call last):File "D:\nlp\zhinengyunwei\wh_lstm_pytorch.py", line 213, in <module>loss = loss_func(torch.squeeze(output), target)File "D:\ProgramData\Anaconda3\lib\site-pack
·
Traceback (most recent call last):
File "D:\nlp\zhinengyunwei\wh_lstm_pytorch.py", line 213, in <module>
loss = loss_func(torch.squeeze(output), target)
File "D:\ProgramData\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "D:\ProgramData\Anaconda3\lib\site-packages\torch\nn\modules\loss.py", line 1150, in forward
return F.cross_entropy(input, target, weight=self.weight,
File "D:\ProgramData\Anaconda3\lib\site-packages\torch\nn\functional.py", line 2846, in cross_entropy
return torch._C._nn.cross_entropy_loss(input, target, weight, _Reduction.get_enum(reduction), ignore_index, label_smoothing)
RuntimeError: "nll_loss_forward_reduce_cuda_kernel_2d_index" not implemented for 'Float'
发生在loss计算的时候,
将
loss_func(torch.squeeze(output), target)
改为:
loss_func(torch.squeeze(output), target.long())
更多推荐
已为社区贡献22条内容
所有评论(0)