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

为什么训练之后的pth,在进行load时报错 #42

Closed
wgc-hub opened this issue May 4, 2023 · 4 comments
Closed

为什么训练之后的pth,在进行load时报错 #42

wgc-hub opened this issue May 4, 2023 · 4 comments

Comments

@wgc-hub
Copy link

wgc-hub commented May 4, 2023

我下载的pth文件可以进行load,但是在训练之后为什么就不可以了,是因为模型结构发生了变化吗,那我应该怎么加载呢,比如当我想要进行部署的时候

@Fafa-DL
Copy link
Owner

Fafa-DL commented May 5, 2023

你是训练的时候修改了网络结构还是什么?按正常流程训练完加载是没问题的,要么就是cfg相应位置没修改

@wgc-hub
Copy link
Author

wgc-hub commented May 6, 2023

你是训练的时候修改了网络结构还是什么?按正常流程训练完加载是没问题的,要么就是cfg相应位置没修改

我通过torchvision加载了一个mobilenet_v3_small网络模型,进行torch.load可以正常加载
截屏2023-05-06 14 04 22
然后我把它训练一次之后得到的权重文件,在进行如上图一样的加载,就会报错,好像网络结构不一致了。
截屏2023-05-06 14 09 56

@wgc-hub
Copy link
Author

wgc-hub commented May 6, 2023

你是训练的时候修改了网络结构还是什么?按正常流程训练完加载是没问题的,要么就是cfg相应位置没修改

或者说我经过咱们这个系统训练完的pth文件,应该怎么在别的地方加载呢

@Fafa-DL
Copy link
Owner

Fafa-DL commented May 7, 2023

torchvision对应的网络模型键名对不上当然权重无法映射,得在该项目下训才可以

@Fafa-DL Fafa-DL closed this as completed Jun 3, 2023
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