I am following the Pytorch tutorial on the DCgan, and was trying to view the output images from the model individually, instead as grid. This is the code used:

generating new images

sets a random seed
manualSeed = random.randint(1, 10000) # use if you want new results
print("Random Seed: ", manualSeed)
random.seed(manualSeed)
torch.manual_seed(manualSeed)
fake = gen(torch.randn(1, n_z, 1, 1, device=‘cpu’)).detach()
plt.figure(figsize=(15, 15))
plt.imshow(fake)
…
I am able to view the output as a grid using the following function, but that doesn’t serve my purpose since I would like to save each image later using a loop function.
plt.imshow(np.transpose(vutils.make_grid(fake, padding=2, normalize=True), (1,2,0)))
I was also viewing the tutorial of https://github.com/ayan-aji-nair/art-generation-gan/blob/main/Notebooks/DCGAN_128.ipynb 1 which is an adaptation of Pytorch’s version.