rayleizhu / BiFormer

[CVPR 2023] Official code release of our paper "BiFormer: Vision Transformer with Bi-Level Routing Attention"
https://arxiv.org/abs/2303.08810
MIT License
500 stars 41 forks source link

TypeError: '>' not supported between instances of 'tuple' and 'int' #20

Closed zi1zi closed 1 year ago

zi1zi commented 1 year ago

感谢您出色的工作,但是我把代码加入到我的baseline中出现了如标题所示的错误, 出错的代码位置如下:bra_legacy.py self.lepe = nn.Conv2d(dim, dim, kernel_size=side_dwconv, stride=1, padding=side_dwconv//2, groups=dim) if side_dwconv > 0 else \ lambda x: torch.zeros_like(x)

rayleizhu commented 1 year ago

你代码写错了。加一行print(side_dwconv) 来debug。

这种问题建议google。

zi1zi commented 1 year ago

感谢您的及时回复,但是我直接是将文件复制过去的,我打印了一下print(side_dwconv),输出的是(3,), 我感觉side_dwconv是tuple类型的无法与0int类型的直接比较,但是我if side_dwconv > 0改为side_dwconv[0] > 0又出现TypeError: unsupported operand type(s) for //: 'tuple' and 'int'

rayleizhu commented 1 year ago

你参数传错了,side_dwconv给个int值,而不是tuple。我的代码里面默认是5。

https://github.com/rayleizhu/BiFormer/blob/1697bbbeafb8680524898f1dcaac10defd0604be/models/biformer_stl_nchw.py#L227

zi1zi commented 1 year ago

好的,我明白了,感谢及时回复