TypeError: div() got an unexpected keyword argument ‘rounding_mode’

报错代码:torch.div(…, …, rounding_mode=“floor”)

mask_idx = torch.div(idx, self.instance_classes, rounding_mode=“floor”)

报错原因: rounding_mode在torch1.8才引入

https://github.com/mit-han-lab/torchsparse/pull/126
torch.div()方法的rounding_mode参数 似乎是torch1.8才引入的,我的torch版本太老了

解决方法:在torch.div()外面再套一层torch.floor()

可以升级torch到1.8以上,但如果不想升级:
根据torch官方文档:
https://pytorch.org/docs/stable/generated/torch.div.html

“floor” - rounds the results of the division down. Equivalent to floor division in Python (the // operator) and NumPy’s np.floor_divide.

在这里插入图片描述

那我直接再套一层floor代替呗。
这样跑起来和官方的例子一样,完美:
在这里插入图片描述
最终解决办法:

# mask_idx = torch.div(idx, self.instance_classes, rounding_mode="floor")
mask_idx = torch.floor(torch.div(idx, self.instance_classes)) # modified by Qiao for torch<1.8

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值