RuntimeError: result type Float can’t be cast to the desired output type long
改为:
test_loss = criterion(y_pred, y_gt.float()).item()
在代码中遇到了一个`RuntimeError`,问题在于尝试将浮点型结果转换为长整型,但该操作不被支持。解决方案是将`y_gt`转换为浮点型再进行计算,如`test_loss=criterion(y_pred,y_gt.float()).item()`。这涉及到Python数据类型转换和深度学习损失函数的正确使用。
RuntimeError: result type Float can’t be cast to the desired output type long
改为:
test_loss = criterion(y_pred, y_gt.float()).item()
2万+
1万+
1375

被折叠的 条评论
为什么被折叠?