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

Function saveImage

cnn-CGANCode/utils.py:17–27  ·  view source on GitHub ↗
(generator,epoch,)

Source from the content-addressed store, hash-verified

15
16
17def saveImage(generator,epoch,):
18 noise = torch.randn(size=(8, config.LATENT_DIM, 1, 1)).to(config.DEVICE)
19 # fixed labels
20 y_ = (torch.rand(8, 1) * config.NUM_CLASSES).type(torch.LongTensor)
21 y_fixed = torch.zeros(8, config.NUM_CLASSES)
22 y_fixed = y_fixed.scatter_(1, y_.view(8, 1), 1).view(8, config.NUM_CLASSES, 1, 1)
23 y_fixed = y_fixed.to(config.DEVICE)
24
25 gen_imgs = generator(noise, y_fixed).view(-1, config.CHANNELS, config.IMG_SIZE, config.IMG_SIZE)
26
27 save_image(gen_imgs.data, 'save' + '/%d.png' % (epoch))
28
29
30def gradient_penalty(critic, real, fake, device):

Callers 1

mainFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected