“nll_loss_forward_reduce_cuda_kernel_2d_index“ not implemented for ‘Float‘
Posted AI浩
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了“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-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())
以上是关于“nll_loss_forward_reduce_cuda_kernel_2d_index“ not implemented for ‘Float‘的主要内容,如果未能解决你的问题,请参考以下文章