MCPcopy Create free account
hub / github.com/KeepTryingTo/Pytorch-GAN / generate_examples

Function generate_examples

ProGAN/demo.py:282–294  ·  view source on GitHub ↗

Tried using truncation trick here but not sure it actually helped anything, you can remove it if you like and just sample from torch.randn

(gen, steps, truncation=0.7, n=100)

Source from the content-addressed store, hash-verified

280 torch.backends.cudnn.benchmark = False
281
282def generate_examples(gen, steps, truncation=0.7, n=100):
283 """
284 Tried using truncation trick here but not sure it actually helped anything, you can
285 remove it if you like and just sample from torch.randn
286 """
287 gen.eval()
288 alpha = 1.0
289 for i in range(n):
290 with torch.no_grad():
291 noise = torch.tensor(truncnorm.rvs(-truncation, truncation, size=(1,Z_DIM, 1, 1)), device=DEVICE, dtype=torch.float32)
292 img = gen(noise, alpha, steps)
293 save_image(img*0.5+0.5, f"saved_examples/img_{i}.png")
294 gen.train()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected