Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于阻止已经置零的通道进行权重更新出现的问题 #38

Open
dlgyy opened this issue Jan 5, 2020 · 2 comments
Open

关于阻止已经置零的通道进行权重更新出现的问题 #38

dlgyy opened this issue Jan 5, 2020 · 2 comments

Comments

@dlgyy
Copy link

dlgyy commented Jan 5, 2020

我对您的工作感到很感兴趣,也在进行相关的研究,在实验的过程中,发现了一些有意思的现象,希望能与您进行讨论。
for m in model.modules():
if isinstance(m, nn.BatchNorm2d) or isinstance(m, nn.BatchNorm1d):
mask = (m.weight.data != 0)
mask = mask.float().cuda()
m.weight.grad.data.mul_(mask)
m.bias.grad.data.mul_(mask)
这部分代码是您用来阻止已经置零的权重进行进一步的梯度更新,这是很不错的想法,我也想在自己的工作中加入这部分代码,但是在pytorch中发现这部分代码并不能绝对的阻止权重的更新。虽然直观上他应该可以阻止参数的更新,但是实际上,那些已经置零的通道仍然会进行少量的更新。这样的一个直接的影响就是,应该失效的通道仍然在默默的发挥作用。不知道您是否注意到这种情况,期待您的回复。

@Eric-mingjie
Copy link
Owner

Eric-mingjie commented Jan 5, 2020

虽然直观上他应该可以阻止参数的更新

不是直观上,而是理论上那些已经置零的通道不会发挥作用。

@kaijieshi7
Copy link

我有点不大清楚,是不是将已经置零的部分的梯度乘以0?这样子阻止它的更新?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants