在跑U版本的RT-DETR,我修改了RepC3的e的默然参数,e 不等于1的时候,程序就会报错,在检查代码的时候,发现官方的代码有问题。
原来的代码:
class RepC3(nn.Module):
"""Rep C3."""
def __init__(self, c1, c2, n=3, e=1.0):
"""Initialize CSP Bottleneck with a single convolution using input channels, output channels, and number."""
super().__init__()
c_ = int(c2 * e) # hidden channels
self.cv1 = Conv(c1, c2, 1, 1)
self.cv2 = Conv(c1, c2, 1, 1)
self.m = nn.Sequential(*[RepConv(c_, c_) for _ in range(n)])
self.cv3 = Conv(c_, c2, 1, 1) if c_ != c2 else nn.Identity()
def forward(self, x):
"""Forward pass of RT-DETR neck layer."""
return self.cv3(self.m(self.cv1(x)) + self.cv2(x))
在当前的代码实现中,self.cv1和self.cv2的输出通道数应为隐藏层通道数c_而非最终输出通道数c2,否则会导致维度不匹配的问题。
问题分析:
-
维度不匹配: 当扩展系数


4624

被折叠的 条评论
为什么被折叠?



