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

Miss match for the loaded weight and model? #19

Closed
bezorro opened this issue Sep 10, 2020 · 7 comments
Closed

Miss match for the loaded weight and model? #19

bezorro opened this issue Sep 10, 2020 · 7 comments
Assignees
Labels
help wanted Extra attention is needed

Comments

@bezorro
Copy link
Collaborator

bezorro commented Sep 10, 2020

Another problem: when I run finetune.py with your provided scripts and checkpoint, errors as follow:

Traceback (most recent call last):
  File "finetune.py", line 173, in <module>
    main(opt)
  File "finetune.py", line 90, in main
    net.load_checkpoint(opt.checkpoint)
  File "/home/yeluyue/lz/program/EagleEye/models/wrapper.py", line 122, in load_checkpoint
    module.weight = torch.nn.Parameter(checkpoint[key + ".weight"])
KeyError: 'layers.0.conv1.weight'

Originally posted by @BlossomingL in #18 (comment)

@bezorro
Copy link
Collaborator Author

bezorro commented Sep 10, 2020

It seems that the model does not match the pre-trained weight.
Can I see your script?
@BlossomingL

@BlossomingL
Copy link

python3 finetune.py \
--model_name mobilenetv1 \
--num_classes 1000 \
--checkpoint models/ckpt/imagenet_mobilenet_full_model.pth \
--gpu_ids 0 \
--batch_size 512 \
--dataset_path /home/yeluyue/lz/dataset/ImageNet2012 \
--dataset_name imagenet \
--exp_name mbv1_50flops_3 \
--search_result search_results/best_strategy_mbv1_50flops.txt \
--strategy_id 1 \
--epoch 120 \
--lr 1e-2 \
--weight_decay 5e-4

@bezorro
Copy link
Collaborator Author

bezorro commented Sep 10, 2020

python3 finetune.py \
--model_name mobilenetv1 \
--num_classes 1000 \
--checkpoint models/ckpt/imagenet_mobilenet_full_model.pth \
--gpu_ids 0 \
--batch_size 512 \
--dataset_path /home/yeluyue/lz/dataset/ImageNet2012 \
--dataset_name imagenet \
--exp_name mbv1_50flops_3 \
--search_result search_results/best_strategy_mbv1_50flops.txt \
--strategy_id 1 \
--epoch 120 \
--lr 1e-2 \
--weight_decay 5e-4

Try >> print(torch.load(opt.checkpoint).keys()) to see if the loaded weight matches the model.

@BlossomingL
Copy link

OK, thanks, I have solved it.

@BlossomingL
Copy link

I also search max accuracy on ResNet-50, the top-5 accuracy as follow, can I prune and finetune ResNet-50 on these parameters?

strategy index:49, score:0.133
strategy index:165, score:0.122
strategy index:94, score:0.117
strategy index:290, score:0.102
strategy index:22, score:0.101

@bezorro
Copy link
Collaborator Author

bezorro commented Sep 10, 2020

OK, thanks, I have solved it.

Why the bug occured, is there a bug inside our code?

@BlossomingL
Copy link

BlossomingL commented Sep 10, 2020

OK, thanks, I have solved it.

Why the bug occured, is there a bug inside our code?

No, I'm sorry it's my careless.

@bezorro bezorro added the help wanted Extra attention is needed label Sep 10, 2020
@bezorro bezorro closed this as completed Sep 10, 2020
@bezorro bezorro changed the title Another problem: when I run finetune.py with your provided scripts and checkpoint, errors as follow: Miss match for the loaded weight and model? Sep 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants