RuntimeError: result type Float can‘t be cast to the desired output type long int

Posted MMM881

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了RuntimeError: result type Float can‘t be cast to the desired output type long int相关的知识,希望对你有一定的参考价值。

将loss.py中gain = torch.ones(7, device=targets.device)改为gain = torch.ones(7, device=targets.device).long()即可。

原因是新版本的torch无法自动执行此转换,旧版本torch可以。

以上是关于RuntimeError: result type Float can‘t be cast to the desired output type long int的主要内容,如果未能解决你的问题,请参考以下文章

一步真实解决RuntimeError: result type Float can‘t be cast to the desired output type long int

RuntimeError:永远不要在任务 Celery 中调用 result.get()

RuntimeError: Expected object of type torch.cuda.FloatTensor but found type torch.FloatTensor for ar

RuntimeError: Bool type is not supported by dlpack

RuntimeError: Bool type is not supported by dlpack

RuntimeError: Input type (torch.cuda.DoubleTensor) and weight type (torch.cuda.FloatTensor) should b