Skip to content

Commit feb757b

Browse files
author
Allard Hendriksen
committed
Fix weights access when pruning in pytorch 1.4
Patch based on discussion at: https://discuss.pytorch.org/t/forward-pre-hooks-not-called-after-applying-nn-uitls-prune-methods/69497 This patch has been tested by Richard Schoonhoven.
1 parent c09f48d commit feb757b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

msd_pytorch/msd_block.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,6 @@ def forward(self, input):
176176
# `self.parameters()`, but this returns the original
177177
# (unmasked) parameters.
178178
bias = self.bias
179-
weights = (self.__getattr__("weight{}".format(i)) for i in range(len(self.weights)))
179+
weights = (getattr(self, "weight{}".format(i)) for i in range(len(self.weights)))
180180

181181
return MSDBlockImpl2d.apply(input, self.dilations, bias, *weights)

0 commit comments

Comments
 (0)