Skip to content

AttributeError: 'PrunerModuleWrapper' object has no attribute 'weight' #3798

Answered by J-shang
damon-93 asked this question in Q&A
Discussion options

You must be logged in to vote

@damon-93 @sergiogcharles @FTdiscovery
Sorry for I lose apply_compression_results() in the above code. And I corrected the code.

            model_sp = LeNet().to(device)
            model_sp.load_state_dict(torch.load(model_path))
            apply_compression_results(model_sp, mask_path)
            dummy_input = torch.randn([args.batch_size, 1, 28, 28]).to(device)
            m_speedup = ModelSpeedup(model_sp, dummy_input, mask_path, device)
            m_speedup.speedup_model()
            torch.save(model_sp.state_dict(), "use_mask_small_model.pth")

Yes, you are right, apply_compression_results() is required.

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by scarlett2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
4 participants
Converted from issue

This discussion was converted from issue #3658 on June 10, 2021 02:02.