Skip to content

Commit

Permalink
Merge pull request #11 from mj-will/fix-batch-norm-memory-leak
Browse files Browse the repository at this point in the history
Fix memory leak in batch norm
  • Loading branch information
arturbekasov authored Jul 11, 2020
2 parents 84dc029 + 36dcabc commit 6244a7d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions nflows/transforms/normalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ def forward(self, inputs, context=None):

if self.training:
mean, var = inputs.mean(0), inputs.var(0)
self.running_mean.mul_(1 - self.momentum).add_(mean * self.momentum)
self.running_var.mul_(1 - self.momentum).add_(var * self.momentum)
self.running_mean.mul_(1 - self.momentum).add_(mean.detach() * self.momentum)
self.running_var.mul_(1 - self.momentum).add_(var.detach() * self.momentum)
else:
mean, var = self.running_mean, self.running_var

Expand Down

0 comments on commit 6244a7d

Please sign in to comment.