Git Product home page Git Product logo

Comments (3)

Aarsh2001 avatar Aarsh2001 commented on June 8, 2024

So you can either use torch_summary(package) if you want all the parameter details and model size which outputs something like this
Screenshot 2021-05-22 at 11 35 07 AM
if you only want size you can do something like this

def print_size_of_model(model):
    torch.save(model.state_dict(), "temp.p")
    print('Size (MB):', os.path.getsize("temp.p")/1e6)
    os.remove('temp.p')
print_size_of_model(model)

from torch-pruning.

AIbeginner2020 avatar AIbeginner2020 commented on June 8, 2024

By using the print_size_of_model method, the pruned model size shown did'nt reduce because I think this is cause by even the value is prune (turn to 0),but is still store with fp32. So I wonder how did you get your pruned model size?

image

from torch-pruning.

Aarsh2001 avatar Aarsh2001 commented on June 8, 2024

Yeah so you're using Pytorch's pruning which is unstructured . what unstructured pruning does is that it will put zeros in your weight matrix but it won't remove them. In essence you have a sparse matrix but you're still saving the zeros(those floating point fp32's). If you want model size reduction use this library(torch_pruning), which uses structured pruning or you might want to look into quantization

from torch-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.