SA-Net icon indicating copy to clipboard operation
SA-Net copied to clipboard

ValueError: not enough values to unpack (expected 2, got 1)

Open fanghua2021 opened this issue 4 years ago • 3 comments

我在yolov5中插入sanet,出现错误 x_0, x_1 = x.chunk(2, dim=1) ValueError: not enough values to unpack (expected 2, got 1)

因此我打印出他们的形状 def forward(self, x): b, c, h, w = x.shape print(x.shape) x = x.reshape(b // 2, 2, h, w) print(x.shape) x_0, x_1 = x.chunk(2, dim=1) 输出为为(1,256,32,32) (256,1,32,32)

请问如何解决问题呢?

fanghua2021 avatar Jan 17 '22 08:01 fanghua2021

请问您解决这个问题了吗,我遇到的错误和您的一样。 x_0, x_1 = x.chunk(2, dim=1) ValueError: not enough values to unpack (expected 2, got 1)

另外,我想问问您,为什么您的代码中改成x = x.reshape(b // 2, 2, h, w)而不是x = x.reshape(b * self.groups, -1, h, w)

Tou-ge avatar Apr 01 '22 01:04 Tou-ge

请问您解决这个问题了吗,我遇到的错误和您的一样。

shl-ybu avatar May 08 '22 11:05 shl-ybu

请问你解决这个问题了吗,我也是一模一样的报错。我还研究了一下chunk函数的用法,发现它返回的就只是一个张量,也就是只能得到一个值,所以根本不可能会分成两个值分别赋值给x_0, x_1,感觉是不是这个代码本身写错了啊

YL-laughtale avatar Jun 27 '22 09:06 YL-laughtale