Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

size mismatch #24

Open
fengchenTM opened this issue Oct 30, 2023 · 3 comments
Open

size mismatch #24

fengchenTM opened this issue Oct 30, 2023 · 3 comments

Comments

@fengchenTM
Copy link

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

@fengchenTM
Copy link
Author

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

@achusky
Copy link
Collaborator

achusky commented Oct 31, 2023

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

@fengchenTM
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants