RuntimeError: “nll_loss_forward_reduce_cuda_kernel_2d_index” not implemented for ‘Float’
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/zz/anaconda3/envs/torch1.11/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
return forward_call(*input, **kwargs)
File "/home/zz/anaconda3/envs/torch1.11/lib/python3.7/site-packages/torch/nn/modules/loss.py", line 1165, in forward
label_smoothing=self.label_smoothing)
File "/home/zz/anaconda3/envs/torch1.11/lib/python3.7/site-packages/torch/nn/functional.py", line 2996, 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'
需要将一维的label 改为的label.long()
CEloss = nn.CrossEntropyLoss()
CEloss(node_mask_pred, labels.squeeze().long()