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

load_state_dict #157

Open
YiDanCheung opened this issue Aug 31, 2024 · 3 comments
Open

load_state_dict #157

YiDanCheung opened this issue Aug 31, 2024 · 3 comments
Labels
question Further information is requested

Comments

@YiDanCheung
Copy link

Thank you for your outstanding work!

But I'm wondering how to use load_state_dict(), in episodic_training.ipynb you use few_shot_classifier.load_state_dict(best_state), but classical_training.ipynb you use model.load_state_dict(best_state) while the the former is PrototypicalNetworks and the latter is resnet12.

Looking for your reply!

@YiDanCheung YiDanCheung added the question Further information is requested label Aug 31, 2024
@ebennequin
Copy link
Collaborator

It's because in episodic training we train the few-shot classifier, while in classical training we only train the feature extractor.

@YiDanCheung
Copy link
Author

It's because in episodic training we train the few-shot classifier, while in classical training we only train the feature extractor.

So maybe in classical_training.ipynb best_state = copy.deepcopy(few_shot_classifier.state_dict()) should be best_state = copy.deepcopy(model.state_dict()), and it would not cause error like RuntimeError: Error(s) in loading state_dict for ResNet : Missing key(s) in state_dict: "conv1.weight", ...

@ebennequin ebennequin reopened this Sep 4, 2024
@ebennequin
Copy link
Collaborator

Indeed! It's a mistake that we introduced in this commit. We should make the change.

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

No branches or pull requests

2 participants