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

An error occurs when running eval_sampled_config.py #2

Closed
hnz71211 opened this issue Jul 2, 2021 · 3 comments · Fixed by #4
Closed

An error occurs when running eval_sampled_config.py #2

hnz71211 opened this issue Jul 2, 2021 · 3 comments · Fixed by #4
Assignees

Comments

@hnz71211
Copy link

hnz71211 commented Jul 2, 2021

An error occurs when loading pre-trained weight file (saved in ofa/checkpoints) to Comp-OFAMobileNetV3 net.

python eval_sampled_config.py --net ofa/checkpoints/model_best_compofa_simple.pth.tar --imagenet_path imagenet

The error is:

File "*/CompOFA/eval_sampled_config.py", line 85, in <module>
    net.load_weights_from_net(torch.load(args.net, map_location='cpu')['state_dict'])
  File "*/CompOFA/ofa/elastic_nn/networks/ofa_mbv3.py", line 215, in load_weights_from_net
    raise ValueError(key)

ValueError: blocks.1.mobile_inverted_conv.depth_conv.conv.5to3_matrix

Could you tell me how to solve this problem?

@howardgriffin
Copy link

I have the same problem, did you resolve it? @hnz71211

@AdityaAS AdityaAS self-assigned this Feb 16, 2022
@PhungLai728
Copy link

PhungLai728 commented Jan 4, 2023

I have the same problem. And the way I overcome it is that I modified the load_weights_from_net() function in ofa_mbv3.py from
for key in src_model_dict: if key in model_dict:
to be
for key in model_dict: if key in src_model_dict:
Hope it help!

@sahnimanas
Copy link
Collaborator

Those stray keys can be ignored when loading fixed kernel models, and this has now been fixed in #4
Reading keys from model_dict would bypass the key transformations for other keys (if conditions in later lines), I haven't checked how that affects those cases.

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

Successfully merging a pull request may close this issue.

5 participants