返回顶部

深度学习模型训练时报错“nll_loss_forward_reduce_cuda_kernel_2d_index“ not implemented for ‘Float‘问题解决

报错如下:

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())

 

posted @ 2023-09-08 22:40  欣杰科技  阅读(2433)  评论(0)    收藏  举报