Pytorch报错:RuntimeError: "exp" not implemented for 'torch.IntTensor'或者是'torch.LongTensor'

报错展示:

目的是以下实现函数:

原先输入变量是:torch.int64报错是:

然后尝试将torch.LongTensor转换为:torch.IntTensor类型:

注意强制转换的操作是:直接在变量后面添加.int()、.folat()等,进行变量类型的变换。

无奈的是还存在同样的错误。

然后,尝试将torch.LongTensor转换为:torch.FolatTensor类型:

测试代码,报错解决。

总结:在Pytorch下的torch的exp运算是针对浮点数据类型的。

猜你喜欢

转载自blog.csdn.net/songchunxiao1991/article/details/83544578
今日推荐