错误:RuntimeError: result type Float can’t be cast to the desired output type long int
翻译:RuntimeError: 结果类型Float无法强制转换为所需的输出类型long int
原因:新版本的torch无法自动执行转换操作,而旧版本可以。本文中报错版本为torch 1.13.1, torchaudio 0.13.1, torchvision 0.14.1
。
解决方法:定位报错语句,确定参与计算的对象的数据类型,统一数据类型。
案例:
报错信息:
代码定位:
检查b, a, gj, gain
的数据类型,发现gain
中元素为float
类型,手动将其改为long
。如下,
参考资料
解决错误:RuntimeError: result type Float can‘t be cast to the desired output type __int64