Skip to content

Commit

Permalink
Merge branch 'main' of github.com:rosinality/alias-free-gan-pytorch i…
Browse files Browse the repository at this point in the history
…nto main
  • Loading branch information
rosinality committed Aug 8, 2021
2 parents 9dfd125 + 7cb5f4a commit 6985087
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions train.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def requires_grad(model, flag=True):
for p in model.parameters():
p.requires_grad = flag


@torch.no_grad()
def accumulate(model1, model2, decay=0.999):
par1 = dict(model1.named_parameters())
par2 = dict(model2.named_parameters())
Expand Down Expand Up @@ -293,16 +293,19 @@ def train(conf, loader, generator, discriminator, g_optim, d_optim, g_ema, devic
)

if i % 100 == 0:
generator.zero_grad()
discriminator.zero_grad()
with torch.no_grad():
g_ema.eval()
sample = g_ema(sample_z)
sample = g_ema(sample_z).cpu()
utils.save_image(
sample,
f"sample/{str(i).zfill(6)}.png",
nrow=int(conf.training.n_sample ** 0.5),
normalize=True,
value_range=(-1, 1),
)
sample = None # cleanup memory

if i % 10000 == 0:
torch.save(
Expand Down

0 comments on commit 6985087

Please sign in to comment.