Closed EarendelH closed 11 months ago
这个不是报错哈,只是一个警告。这个警告是针对 C // self.num_head
语句,torch提示现在会默认使用trunc
取整策略,其实这个警告可以忽略,因为当前语义中的 C
肯定self.num_head
的整数倍,所以可以不用管。
如果你非要改掉,可以参考下面代码:
qkv = self.qkv(x).reshape(B, N, 3, self.num_heads, torch.div(C, self.num_heads, rounding_mode='floor')).permute(2, 0, 3, 1, 4)
老师你好,在使用vision_transformer的flops.py进行测试的时候有报错 UserWarning: floordiv is deprecated, and its behavior will change in a future version of pytorch. It currently rounds toward 0 (like the 'trunc' function NOT 'floor'). This results in incorrect rounding for negative values. To keep the current behavior, use torch.div(a, b, rounding_mode='trunc'), or for actual floor division, use torch.div(a, b, rounding_mode='floor'). qkv = self.qkv(x).reshape(B, N, 3, self.num_heads, C // self.num_heads).permute(2, 0, 3, 1, 4) 对应vit_model.py中Attention/forward中的yujv qkv = self.qkv(x).reshape(B, N, 3, self.num_heads, C // self.num_heads).permute(2, 0, 3, 1, 4) 请问该如何修改,我尝试修改为 qkv = torch.div(self.qkv(x).reshape(B, N, 3, self.num_heads, C // self.num_heads), rounding_mode='trunc').permute(2, 0, 3, 1, 4) 后会报错缺少必要的”other“参数,阅读div的用法后必要参数是”input“和”other“,请问参数的对应关系是什么??