TLC icon indicating copy to clipboard operation
TLC copied to clipboard

size mismatch

Open fengchenTM opened this issue 1 year ago • 3 comments

我输入一张图片大小为(2160,3672), 经过class AvgPool2d的输出维度是(1, 1,1945, 3457),训练时用的AdaptiveAvgPool2d(1) 再经过flatten,fc就不能正常匹配维度了 请问该怎么修改 image

fengchenTM avatar Oct 30 '23 14:10 fengchenTM

TLC是不是只能用在用Conv来实现的全连接层上,不然局部平均池化的输出为(C,H,W)与全局平均池化的输出(C,1,1)对不上

fengchenTM avatar Oct 31 '23 03:10 fengchenTM

是的,需要使用Conv实现的全连接层来处理(C,H,W)的输出。你可以将训练好的nn.Linear中的weight经过变换之后载入到重新实现的nn.Conv2d当中,并取消torch.flatten操作。

achusky avatar Oct 31 '23 03:10 achusky

哇,谢谢你如此快速的回复

fengchenTM avatar Oct 31 '23 03:10 fengchenTM