zepx / pytorch-weight-prune Goto Github PK
View Code? Open in Web Editor NEWPytorch version for weight pruning for Murata Group's CREST project
Pytorch version for weight pruning for Murata Group's CREST project
Hi, I'm relatively new to deep learning area, and studying network pruning methods. This repository have helped me a lot to understand key ideas of pruning. Thank you :)
By the way, I have one question on the masked layer classes.
When setting the mask, the weight matrix of the layer is multiplicated with mask. However, it is multiplicated once more on forward
. More specifically, these lines.
on set_mask
: self.weight.data = self.weight.data*mask_var.data
on forward
: weight = self.weight * mask_var
Is it on purpose?, if yes, could you explain why?
I'll wait for the reply. Have a joyful day!
class MaskedLinear(nn.Linear):
def __init__(self, in_features, out_features, bias=True):
super(MaskedLinear, self).__init__(in_features, out_features, bias)
self.mask_flag = False
def set_mask(self, mask):
self.register_buffer('mask', mask)
mask_var = self.get_mask()
self.weight.data = self.weight.data*mask_var.data
self.mask_flag = True
def get_mask(self):
# print(self.mask_flag)
return to_var(self.mask, requires_grad=False)
def forward(self, x):
if self.mask_flag == True:
mask_var = self.get_mask()
weight = self.weight * mask_var
return F.linear(x, weight, self.bias)
else:
return F.linear(x, self.weight, self.bias)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.