Git Product home page Git Product logo

Comments (7)

 avatar commented on August 29, 2024

@wuzhiyang2016 I've got the same problem. I added the ModifiedVGG16Model class in my test script, with no success. Do you still have the same issue?

from pytorch-pruning.

 avatar commented on August 29, 2024

@jacobgil Any idea?

from pytorch-pruning.

jacobgil avatar jacobgil commented on August 29, 2024

The code in the repo saves the entire model with pickling, instead of the state dict, which is actually a bad practice.
A better way would be to save only the state_dict, and then load it.
Going to change it now to

state_dict = model.state_dict()
save(state_dict, 'model.chkpt')

Then you can load the model like this:

model = ModifiedVGG16Model()
checkpoint = torch.load(checkpoint_path, \
        map_location=lambda storage, loc: storage)
model.load_state_dict(checkpoint)
model.eval()

from pytorch-pruning.

wuzhiyang2016 avatar wuzhiyang2016 commented on August 29, 2024

@wuzhiyang2016 I've got the same problem. I added the ModifiedVGG16Model class in my test script, with no success. Do you still have the same issue?

like the author, when we load the saved model , ModifiedVGG16Model() should be defined

from pytorch-pruning.

mlcoop avatar mlcoop commented on August 29, 2024

@jacobgil Hey! There is a problem with size mismatch. For example: RuntimeError: Error(s) in loading state_dict for ModifiedVGG16Model: size mismatch for features.0.weight: copying a param with shape torch.Size([50, 3, 3, 3]) from checkpoint, the shape in current model is torch.Size([64, 3, 3, 3]). size mismatch for features.0.bias: copying a param with shape torch.Size([50]) from checkpoint, the shape in current model is torch.Size([64]). size mismatch for features.2.weight: copying a param with shape torch.Size([44, 50, 3, 3]) from checkpoint, the shape in current model is torch.Size([64, 64, 3, 3]).

Is there way to solve it ?

from pytorch-pruning.

ms-krajesh avatar ms-krajesh commented on August 29, 2024

@jacobgil Hey! There is a problem with size mismatch. For example: RuntimeError: Error(s) in loading state_dict for ModifiedVGG16Model: size mismatch for features.0.weight: copying a param with shape torch.Size([50, 3, 3, 3]) from checkpoint, the shape in current model is torch.Size([64, 3, 3, 3]). size mismatch for features.0.bias: copying a param with shape torch.Size([50]) from checkpoint, the shape in current model is torch.Size([64]). size mismatch for features.2.weight: copying a param with shape torch.Size([44, 50, 3, 3]) from checkpoint, the shape in current model is torch.Size([64, 64, 3, 3]).

Is there way to solve it ?

@jacobgil : Since the pruned model will be having different in and out filters in each layer. Is there any way to load the pruned model state dictionary with original model class?

from pytorch-pruning.

mlcoop avatar mlcoop commented on August 29, 2024

@ms-krajesh Probably not a solution but I just rewrote model architecture with altered layer numbers.

from pytorch-pruning.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.