Skip to content

Commit

Permalink
Fixed bug that initialized flag of ActNorm is not saved
Browse files Browse the repository at this point in the history
  • Loading branch information
rosinality committed May 3, 2019
1 parent ddb4b65 commit f332121
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions model.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __init__(self, in_channel, logdet=True):
self.loc = nn.Parameter(torch.zeros(1, in_channel, 1, 1))
self.scale = nn.Parameter(torch.ones(1, in_channel, 1, 1))

self.initialized = False
self.register_buffer('initialized', torch.tensor(0, dtype=torch.uint8))
self.logdet = logdet

def initialize(self, input):
Expand All @@ -42,9 +42,9 @@ def initialize(self, input):
def forward(self, input):
_, _, height, width = input.shape

if not self.initialized:
if self.initialized.item() == 0:
self.initialize(input)
self.initialized = True
self.initialized.fill_(1)

log_abs = logabs(self.scale)

Expand Down

0 comments on commit f332121

Please sign in to comment.