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

Function generate_examples

ProGAN/utils.py:86–98  ·  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

84 torch.backends.cudnn.benchmark = False
85
86def generate_examples(gen, steps, truncation=0.7, n=100):
87 """
88 Tried using truncation trick here but not sure it actually helped anything, you can
89 remove it if you like and just sample from torch.randn
90 """
91 gen.eval()
92 alpha = 1.0
93 for i in range(n):
94 with torch.no_grad():
95 noise = torch.tensor(truncnorm.rvs(-truncation, truncation, size=(1, config.Z_DIM, 1, 1)), device=config.DEVICE, dtype=torch.float32)
96 img = gen(noise, alpha, steps)
97 save_image(img*0.5+0.5, f"saved_examples/img_{i}.png")
98 gen.train()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected