GithubHelp home page GithubHelp logo

Comments (2)

jack-willturner avatar jack-willturner commented on June 6, 2024

Sorry for the slow response.

The easiest way to do this would be to create a normal resnet34 (without masks), and then copy across the weights.

You'll want to do something like:

net = NormalResNet34()
masked_net = MaskedResNet34()

for normal, masked in zip([net.layer1, net.layer2, net.layer3, net.layer4], [masked_net.layer1, masked_net.layer2, masked_net.layer3, masked_net.layer4]):
    normal.conv1.weight = masked.conv1.weight
    normal.bn1.weight = masked.bn1.weight
    normal.conv2.weight  = masked.conv2.weight
    # etc.

Note that you're probably going to have to copy some biases as well (you can just do normal.bn1.bias).

It would be cool to have this as a feature in the code. If you figure it out, please feel free to open a pull request 😊

If not I'll get to implementing it soon.

from deep-compression.

zjykzj avatar zjykzj commented on June 6, 2024

Sorry for the slow response.

The easiest way to do this would be to create a normal resnet34 (without masks), and then copy across the weights.

You'll want to do something like:

net = NormalResNet34()
masked_net = MaskedResNet34()

for normal, masked in zip([net.layer1, net.layer2, net.layer3, net.layer4], [masked_net.layer1, masked_net.layer2, masked_net.layer3, masked_net.layer4]):
    normal.conv1.weight = masked.conv1.weight
    normal.bn1.weight = masked.bn1.weight
    normal.conv2.weight  = masked.conv2.weight
    # etc.

Note that you're probably going to have to copy some biases as well (you can just do normal.bn1.bias).

It would be cool to have this as a feature in the code. If you figure it out, please feel free to open a pull request

If not I'll get to implementing it soon.

Good idea, thank you. @jack-willturner

Using mask for pruning training is a very common way in pruning algorithm. I didn't want to extract effective parameters after mask training before. Your description gives me a specific implementation path (Although using this scheme needs to reimplement a model definition that can customize the number of parameters of each layer)

from deep-compression.

Related Issues (6)

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.